Completed
Push — master ( dd789a...0df2ac )
by cam
02:19 queued 01:12
created
ecrire/inc/log.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 
54 54
 	// si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
55 55
 	if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
56
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
56
+		$logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log';
57 57
 	}
58 58
 
59 59
 	$rotate = 0;
60
-	$pid = '(pid ' . @getmypid() . ')';
60
+	$pid = '(pid '.@getmypid().')';
61 61
 
62 62
 	// accepter spip_log( Array )
63 63
 	if (!is_string($message)) {
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 			$fi = substr($fi, strlen(_ROOT_RACINE));
73 73
 		}
74 74
 		$fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
75
-		$debugverb = "$fi:L$l:$fu" . '():';
75
+		$debugverb = "$fi:L$l:$fu".'():';
76 76
 	}
77 77
 
78
-	$m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
78
+	$m = date('Y-m-d H:i:s').' '.(isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '').' '.$pid.' '
79 79
 		//distinguer les logs prives et publics dans les grep
80 80
 		. $debugverb
81 81
 		. (test_espace_prive() ? ':Pri:' : ':Pub:')
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 		$rotate-- > 0
101 101
 		and function_exists('spip_unlink')
102 102
 	) {
103
-		spip_unlink($logfile . '.' . $rotate);
103
+		spip_unlink($logfile.'.'.$rotate);
104 104
 		while ($rotate--) {
105
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
105
+			@rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1));
106 106
 		}
107 107
 	}
108 108
 
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -11,107 +11,107 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) {
18
-	static $test_repertoire = [];
19
-	static $compteur = [];
20
-	static $debugverb = ''; // pour ne pas le recalculer au reappel
21
-
22
-	if (is_null($logname) or !is_string($logname)) {
23
-		$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
-	}
25
-	if (!isset($compteur[$logname])) {
26
-		$compteur[$logname] = 0;
27
-	}
28
-	if (
29
-		$logname != 'maj'
30
-		and defined('_MAX_LOG')
31
-		and (
32
-			$compteur[$logname]++ > _MAX_LOG
33
-			or !$GLOBALS['nombre_de_logs']
34
-			or !$GLOBALS['taille_des_logs']
35
-		)
36
-	) {
37
-		return;
38
-	}
39
-
40
-	$logfile = ($logdir === null ? _DIR_LOG : $logdir)
41
-		. ($logname)
42
-		. ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
43
-
44
-	if (!isset($test_repertoire[$d = dirname($logfile)])) {
45
-		$test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
46
-		$test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
47
-			$d,
48
-			'',
49
-			false,
50
-			true
51
-		) : false));
52
-	}
53
-
54
-	// si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
55
-	if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
56
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
57
-	}
58
-
59
-	$rotate = 0;
60
-	$pid = '(pid ' . @getmypid() . ')';
61
-
62
-	// accepter spip_log( Array )
63
-	if (!is_string($message)) {
64
-		$message = var_export($message, true);
65
-	}
66
-
67
-	if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
68
-		$debug = debug_backtrace();
69
-		$l = $debug[1]['line'];
70
-		$fi = $debug[1]['file'];
71
-		if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
72
-			$fi = substr($fi, strlen(_ROOT_RACINE));
73
-		}
74
-		$fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
75
-		$debugverb = "$fi:L$l:$fu" . '():';
76
-	}
77
-
78
-	$m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
79
-		//distinguer les logs prives et publics dans les grep
80
-		. $debugverb
81
-		. (test_espace_prive() ? ':Pri:' : ':Pub:')
82
-		. preg_replace("/\n*$/", "\n", $message);
83
-
84
-
85
-	if (
86
-		@is_readable($logfile)
87
-		and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
88
-	) {
89
-		$rotate = $GLOBALS['nombre_de_logs'];
90
-		$m .= "[-- rotate --]\n";
91
-	}
92
-
93
-	$f = @fopen($logfile, 'ab');
94
-	if ($f) {
95
-		fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
96
-		fclose($f);
97
-	}
98
-
99
-	if (
100
-		$rotate-- > 0
101
-		and function_exists('spip_unlink')
102
-	) {
103
-		spip_unlink($logfile . '.' . $rotate);
104
-		while ($rotate--) {
105
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
106
-		}
107
-	}
108
-
109
-	// Dupliquer les erreurs specifiques dans le log general
110
-	if (
111
-		defined('_FILE_LOG')
112
-		and ($logname !== _FILE_LOG)
113
-	) {
114
-		inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
115
-	}
116
-	$debugverb = '';
18
+    static $test_repertoire = [];
19
+    static $compteur = [];
20
+    static $debugverb = ''; // pour ne pas le recalculer au reappel
21
+
22
+    if (is_null($logname) or !is_string($logname)) {
23
+        $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
+    }
25
+    if (!isset($compteur[$logname])) {
26
+        $compteur[$logname] = 0;
27
+    }
28
+    if (
29
+        $logname != 'maj'
30
+        and defined('_MAX_LOG')
31
+        and (
32
+            $compteur[$logname]++ > _MAX_LOG
33
+            or !$GLOBALS['nombre_de_logs']
34
+            or !$GLOBALS['taille_des_logs']
35
+        )
36
+    ) {
37
+        return;
38
+    }
39
+
40
+    $logfile = ($logdir === null ? _DIR_LOG : $logdir)
41
+        . ($logname)
42
+        . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
43
+
44
+    if (!isset($test_repertoire[$d = dirname($logfile)])) {
45
+        $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
46
+        $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
47
+            $d,
48
+            '',
49
+            false,
50
+            true
51
+        ) : false));
52
+    }
53
+
54
+    // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
55
+    if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
56
+        $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
57
+    }
58
+
59
+    $rotate = 0;
60
+    $pid = '(pid ' . @getmypid() . ')';
61
+
62
+    // accepter spip_log( Array )
63
+    if (!is_string($message)) {
64
+        $message = var_export($message, true);
65
+    }
66
+
67
+    if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
68
+        $debug = debug_backtrace();
69
+        $l = $debug[1]['line'];
70
+        $fi = $debug[1]['file'];
71
+        if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
72
+            $fi = substr($fi, strlen(_ROOT_RACINE));
73
+        }
74
+        $fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
75
+        $debugverb = "$fi:L$l:$fu" . '():';
76
+    }
77
+
78
+    $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
79
+        //distinguer les logs prives et publics dans les grep
80
+        . $debugverb
81
+        . (test_espace_prive() ? ':Pri:' : ':Pub:')
82
+        . preg_replace("/\n*$/", "\n", $message);
83
+
84
+
85
+    if (
86
+        @is_readable($logfile)
87
+        and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
88
+    ) {
89
+        $rotate = $GLOBALS['nombre_de_logs'];
90
+        $m .= "[-- rotate --]\n";
91
+    }
92
+
93
+    $f = @fopen($logfile, 'ab');
94
+    if ($f) {
95
+        fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
96
+        fclose($f);
97
+    }
98
+
99
+    if (
100
+        $rotate-- > 0
101
+        and function_exists('spip_unlink')
102
+    ) {
103
+        spip_unlink($logfile . '.' . $rotate);
104
+        while ($rotate--) {
105
+            @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
106
+        }
107
+    }
108
+
109
+    // Dupliquer les erreurs specifiques dans le log general
110
+    if (
111
+        defined('_FILE_LOG')
112
+        and ($logname !== _FILE_LOG)
113
+    ) {
114
+        inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
115
+    }
116
+    $debugverb = '';
117 117
 }
Please login to merge, or discard this patch.
ecrire/inc/autoriser.php 3 patches
Indentation   +650 added lines, -650 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Autorisations
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('base/abstract_sql');
@@ -38,83 +38,83 @@  discard block
 block discarded – undo
38 38
 
39 39
 
40 40
 if (!function_exists('autoriser')) {
41
-	/**
42
-	 * Autoriser une action
43
-	 *
44
-	 * Teste si une personne (par défaut le visiteur en cours) peut effectuer
45
-	 * une certaine action. Cette fonction est le point d'entrée de toutes
46
-	 * les autorisations.
47
-	 *
48
-	 * La fonction se charge d'appeler des fonctions d'autorisations spécifiques
49
-	 * aux actions demandées si elles existent. Elle cherche donc les fonctions
50
-	 * dans cet ordre :
51
-	 *
52
-	 * - autoriser_{type}_{faire}, sinon avec _dist
53
-	 * - autoriser_{type}, sinon avec _dist
54
-	 * - autoriser_{faire}, sinon avec _dist
55
-	 * - autoriser_{defaut}, sinon avec _dist
56
-	 *
57
-	 * Seul le premier argument est obligatoire.
58
-	 *
59
-	 * @note
60
-	 *     Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre,
61
-	 *     la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser
62
-	 *     cette valeur.
63
-	 *
64
-	 *     Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple
65
-	 *     'statistiques', un souligné avant le terme est ajouté afin d'indiquer
66
-	 *     explicitement à la fonction autoriser de ne pas transformer la chaîne en type
67
-	 *     d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')`
68
-	 *
69
-	 * @note
70
-	 *     Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer
71
-	 *     tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart`
72
-	 *     et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet
73
-	 *     d'éviter une possible confusion si une fonction `autoriser_livre_art` existait :
74
-	 *     quel serait le type, quel serait l'action ?
75
-	 *
76
-	 *     Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art',
77
-	 *     la fonction d'autorisation correspondante ne l'aura pas.
78
-	 *     Exemple : `function autoriser_livreart_modifier_dist(...){...}`
79
-	 *
80
-	 * @api
81
-	 * @see autoriser_dist()
82
-	 *
83
-	 * @param string $faire
84
-	 *   une action ('modifier', 'publier'...)
85
-	 * @param string $type
86
-	 *   type d'objet ou nom de table ('article')
87
-	 * @param int $id
88
-	 *   id de l'objet sur lequel on veut agir
89
-	 * @param null|int|array $qui
90
-	 *   - si null on prend alors visiteur_session
91
-	 *   - un id_auteur (on regarde dans la base)
92
-	 *   - un tableau auteur complet, y compris [restreint]
93
-	 * @param null|array $opt
94
-	 *   options sous forme de tableau associatif
95
-	 * @return bool
96
-	 *   true si la personne peut effectuer l'action
97
-	 */
98
-	function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) {
99
-		// Charger les fonctions d'autorisation supplementaires
100
-		static $pipe;
101
-		if (!isset($pipe)) {
102
-			$pipe = 1;
103
-			pipeline('autoriser');
104
-		}
105
-
106
-		$args = func_get_args();
107
-
108
-		return call_user_func_array('autoriser_dist', $args);
109
-	}
41
+    /**
42
+     * Autoriser une action
43
+     *
44
+     * Teste si une personne (par défaut le visiteur en cours) peut effectuer
45
+     * une certaine action. Cette fonction est le point d'entrée de toutes
46
+     * les autorisations.
47
+     *
48
+     * La fonction se charge d'appeler des fonctions d'autorisations spécifiques
49
+     * aux actions demandées si elles existent. Elle cherche donc les fonctions
50
+     * dans cet ordre :
51
+     *
52
+     * - autoriser_{type}_{faire}, sinon avec _dist
53
+     * - autoriser_{type}, sinon avec _dist
54
+     * - autoriser_{faire}, sinon avec _dist
55
+     * - autoriser_{defaut}, sinon avec _dist
56
+     *
57
+     * Seul le premier argument est obligatoire.
58
+     *
59
+     * @note
60
+     *     Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre,
61
+     *     la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser
62
+     *     cette valeur.
63
+     *
64
+     *     Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple
65
+     *     'statistiques', un souligné avant le terme est ajouté afin d'indiquer
66
+     *     explicitement à la fonction autoriser de ne pas transformer la chaîne en type
67
+     *     d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')`
68
+     *
69
+     * @note
70
+     *     Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer
71
+     *     tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart`
72
+     *     et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet
73
+     *     d'éviter une possible confusion si une fonction `autoriser_livre_art` existait :
74
+     *     quel serait le type, quel serait l'action ?
75
+     *
76
+     *     Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art',
77
+     *     la fonction d'autorisation correspondante ne l'aura pas.
78
+     *     Exemple : `function autoriser_livreart_modifier_dist(...){...}`
79
+     *
80
+     * @api
81
+     * @see autoriser_dist()
82
+     *
83
+     * @param string $faire
84
+     *   une action ('modifier', 'publier'...)
85
+     * @param string $type
86
+     *   type d'objet ou nom de table ('article')
87
+     * @param int $id
88
+     *   id de l'objet sur lequel on veut agir
89
+     * @param null|int|array $qui
90
+     *   - si null on prend alors visiteur_session
91
+     *   - un id_auteur (on regarde dans la base)
92
+     *   - un tableau auteur complet, y compris [restreint]
93
+     * @param null|array $opt
94
+     *   options sous forme de tableau associatif
95
+     * @return bool
96
+     *   true si la personne peut effectuer l'action
97
+     */
98
+    function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) {
99
+        // Charger les fonctions d'autorisation supplementaires
100
+        static $pipe;
101
+        if (!isset($pipe)) {
102
+            $pipe = 1;
103
+            pipeline('autoriser');
104
+        }
105
+
106
+        $args = func_get_args();
107
+
108
+        return call_user_func_array('autoriser_dist', $args);
109
+    }
110 110
 }
111 111
 
112 112
 
113 113
 // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger
114 114
 // mais apres la fonction autoriser()
115 115
 if ($f = find_in_path('mes_fonctions.php')) {
116
-	global $dossier_squelettes;
117
-	include_once(_ROOT_CWD . $f);
116
+    global $dossier_squelettes;
117
+    include_once(_ROOT_CWD . $f);
118 118
 }
119 119
 
120 120
 
@@ -142,73 +142,73 @@  discard block
 block discarded – undo
142 142
  */
143 143
 function autoriser_dist($faire, $type = '', $id = 0, $qui = null, $opt = null) {
144 144
 
145
-	// Qui ? visiteur_session ?
146
-	// si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
147
-	if ($qui === null or $qui === '') {
148
-		$qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : [];
149
-		$qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
150
-	} elseif (is_numeric($qui)) {
151
-		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
152
-	}
153
-
154
-	// Admins restreints, on construit ici (pas generique mais...)
155
-	// le tableau de toutes leurs rubriques (y compris les sous-rubriques)
156
-	if (_ADMINS_RESTREINTS and is_array($qui)) {
157
-		$qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : [];
158
-	}
159
-
160
-	spip_log(
161
-		"autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?',
162
-		'autoriser' . _LOG_DEBUG
163
-	);
164
-
165
-	// passer par objet_type pour avoir les alias
166
-	// et supprimer les _
167
-	$type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false));
168
-
169
-	// Si une exception a ete decretee plus haut dans le code, l'appliquer
170
-	if (
171
-		(isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier'))
172
-		or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier'))
173
-	) {
174
-		spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG);
175
-		return true;
176
-	}
177
-
178
-	// Chercher une fonction d'autorisation
179
-	// Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
180
-	// autoriser_faire[_dist], autoriser_defaut[_dist]
181
-	$fonctions = $type
182
-		? [
183
-			'autoriser_' . $type . '_' . $faire,
184
-			'autoriser_' . $type . '_' . $faire . '_dist',
185
-			'autoriser_' . $type,
186
-			'autoriser_' . $type . '_dist',
187
-			'autoriser_' . $faire,
188
-			'autoriser_' . $faire . '_dist',
189
-			'autoriser_defaut',
190
-			'autoriser_defaut_dist'
191
-		]
192
-		: [
193
-			'autoriser_' . $faire,
194
-			'autoriser_' . $faire . '_dist',
195
-			'autoriser_defaut',
196
-			'autoriser_defaut_dist'
197
-		];
198
-
199
-	foreach ($fonctions as $f) {
200
-		if (function_exists($f)) {
201
-			$a = $f($faire, $type, $id, $qui, $opt);
202
-			break;
203
-		}
204
-	}
205
-
206
-	spip_log(
207
-		"$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'),
208
-		'autoriser' . _LOG_DEBUG
209
-	);
210
-
211
-	return $a;
145
+    // Qui ? visiteur_session ?
146
+    // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
147
+    if ($qui === null or $qui === '') {
148
+        $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : [];
149
+        $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
150
+    } elseif (is_numeric($qui)) {
151
+        $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
152
+    }
153
+
154
+    // Admins restreints, on construit ici (pas generique mais...)
155
+    // le tableau de toutes leurs rubriques (y compris les sous-rubriques)
156
+    if (_ADMINS_RESTREINTS and is_array($qui)) {
157
+        $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : [];
158
+    }
159
+
160
+    spip_log(
161
+        "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?',
162
+        'autoriser' . _LOG_DEBUG
163
+    );
164
+
165
+    // passer par objet_type pour avoir les alias
166
+    // et supprimer les _
167
+    $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false));
168
+
169
+    // Si une exception a ete decretee plus haut dans le code, l'appliquer
170
+    if (
171
+        (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier'))
172
+        or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier'))
173
+    ) {
174
+        spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG);
175
+        return true;
176
+    }
177
+
178
+    // Chercher une fonction d'autorisation
179
+    // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
180
+    // autoriser_faire[_dist], autoriser_defaut[_dist]
181
+    $fonctions = $type
182
+        ? [
183
+            'autoriser_' . $type . '_' . $faire,
184
+            'autoriser_' . $type . '_' . $faire . '_dist',
185
+            'autoriser_' . $type,
186
+            'autoriser_' . $type . '_dist',
187
+            'autoriser_' . $faire,
188
+            'autoriser_' . $faire . '_dist',
189
+            'autoriser_defaut',
190
+            'autoriser_defaut_dist'
191
+        ]
192
+        : [
193
+            'autoriser_' . $faire,
194
+            'autoriser_' . $faire . '_dist',
195
+            'autoriser_defaut',
196
+            'autoriser_defaut_dist'
197
+        ];
198
+
199
+    foreach ($fonctions as $f) {
200
+        if (function_exists($f)) {
201
+            $a = $f($faire, $type, $id, $qui, $opt);
202
+            break;
203
+        }
204
+    }
205
+
206
+    spip_log(
207
+        "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'),
208
+        'autoriser' . _LOG_DEBUG
209
+    );
210
+
211
+    return $a;
212 212
 }
213 213
 
214 214
 // une globale pour aller au plus vite dans la fonction generique ci dessus
@@ -226,26 +226,26 @@  discard block
 block discarded – undo
226 226
  * @return bool
227 227
  */
228 228
 function autoriser_exception($faire, $type, $id, $autoriser = true) {
229
-	// une static innaccessible par url pour verifier que la globale est positionnee a bon escient
230
-	static $autorisation;
231
-	if ($autoriser === 'verifier') {
232
-		return isset($autorisation[$faire][$type][$id]);
233
-	}
234
-	if ($autoriser === true) {
235
-		$GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
236
-	}
237
-	if ($autoriser === false) {
238
-		if ($id === '*') {
239
-			unset($GLOBALS['autoriser_exception'][$faire][$type]);
240
-			unset($autorisation[$faire][$type]);
241
-		}
242
-		else {
243
-			unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
244
-			unset($autorisation[$faire][$type][$id]);
245
-		}
246
-	}
247
-
248
-	return false;
229
+    // une static innaccessible par url pour verifier que la globale est positionnee a bon escient
230
+    static $autorisation;
231
+    if ($autoriser === 'verifier') {
232
+        return isset($autorisation[$faire][$type][$id]);
233
+    }
234
+    if ($autoriser === true) {
235
+        $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
236
+    }
237
+    if ($autoriser === false) {
238
+        if ($id === '*') {
239
+            unset($GLOBALS['autoriser_exception'][$faire][$type]);
240
+            unset($autorisation[$faire][$type]);
241
+        }
242
+        else {
243
+            unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
244
+            unset($autorisation[$faire][$type][$id]);
245
+        }
246
+    }
247
+
248
+    return false;
249 249
 }
250 250
 
251 251
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
  * @return bool          true s'il a le droit, false sinon
263 263
  **/
264 264
 function autoriser_defaut_dist($faire, $type, $id, $qui, $opt) {
265
-	return
266
-		$qui['statut'] == '0minirezo'
267
-		and !$qui['restreint'];
265
+    return
266
+        $qui['statut'] == '0minirezo'
267
+        and !$qui['restreint'];
268 268
 }
269 269
 
270 270
 /**
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
  * @return bool
281 281
  */
282 282
 function autoriser_loger_dist($faire, $type, $id, $qui, $opt) {
283
-	if ($qui['statut'] == '5poubelle') {
284
-		return false;
285
-	}
286
-	return true;
283
+    if ($qui['statut'] == '5poubelle') {
284
+        return false;
285
+    }
286
+    return true;
287 287
 }
288 288
 
289 289
 /**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
  * @return bool          true s'il a le droit, false sinon
298 298
  **/
299 299
 function autoriser_ecrire_dist($faire, $type, $id, $qui, $opt) {
300
-	return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']);
300
+    return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']);
301 301
 }
302 302
 
303 303
 /**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
  * @return bool          true s'il a le droit, false sinon
315 315
  **/
316 316
 function autoriser_creer_dist($faire, $type, $id, $qui, $opt) {
317
-	return in_array($qui['statut'], ['0minirezo', '1comite']);
317
+    return in_array($qui['statut'], ['0minirezo', '1comite']);
318 318
 }
319 319
 
320 320
 /**
@@ -332,18 +332,18 @@  discard block
 block discarded – undo
332 332
  **/
333 333
 function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) {
334 334
 
335
-	// Le visiteur a-t-il un statut prevu par la config ?
336
-	if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) {
337
-		return test_previsualiser_objet_champ($type, $id, $qui, $opt);
338
-	}
335
+    // Le visiteur a-t-il un statut prevu par la config ?
336
+    if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) {
337
+        return test_previsualiser_objet_champ($type, $id, $qui, $opt);
338
+    }
339 339
 
340
-	// A-t-on un token de prévisualisation valable ?
341
-	include_spip('inc/securiser_action');
342
-	if (decrire_token_previsu()) {
343
-		return true;
344
-	}
340
+    // A-t-on un token de prévisualisation valable ?
341
+    include_spip('inc/securiser_action');
342
+    if (decrire_token_previsu()) {
343
+        return true;
344
+    }
345 345
 
346
-	return false;
346
+    return false;
347 347
 }
348 348
 
349 349
 /**
@@ -371,58 +371,58 @@  discard block
 block discarded – undo
371 371
  */
372 372
 function test_previsualiser_objet_champ($type = null, $id = 0, $qui = [], $opt = []) {
373 373
 
374
-	// si pas de type et statut fourni, c'est une autorisation generale => OK
375
-	if (!$type) {
376
-		return true;
377
-	}
378
-
379
-	include_spip('base/objets');
380
-	$infos = lister_tables_objets_sql(table_objet_sql($type));
381
-	if (isset($infos['statut'])) {
382
-		foreach ($infos['statut'] as $c) {
383
-			if (isset($c['publie'])) {
384
-				if (!isset($c['previsu'])) {
385
-					return false;
386
-				} // pas de previsu definie => NIET
387
-				$champ = $c['champ'];
388
-				if (!isset($opt[$champ])) {
389
-					return false;
390
-				} // pas de champ passe a la demande => NIET
391
-				$previsu = explode(',', $c['previsu']);
392
-				// regarder si ce statut est autorise pour l'auteur
393
-				if (in_array($opt[$champ] . '/auteur', $previsu)) {
394
-					// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
395
-					// sinon l’auteur en session
396
-					include_spip('inc/securiser_action');
397
-					if ($desc = decrire_token_previsu()) {
398
-						$id_auteur = $desc['id_auteur'];
399
-					} elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
400
-						$id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']);
401
-					} else {
402
-						$id_auteur = null;
403
-					}
404
-
405
-					if (!$id_auteur) {
406
-						return false;
407
-					} elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) {
408
-						// dans ce cas (admin en general), pas de filtrage sur ce statut
409
-					} elseif (
410
-						!sql_countsel(
411
-							'spip_auteurs_liens',
412
-							'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id)
413
-						)
414
-					) {
415
-						return false;
416
-					} // pas auteur de cet objet => NIET
417
-				} elseif (!in_array($opt[$champ], $previsu)) {
418
-					// le statut n'est pas dans ceux definis par la previsu => NIET
419
-					return false;
420
-				}
421
-			}
422
-		}
423
-	}
424
-
425
-	return true;
374
+    // si pas de type et statut fourni, c'est une autorisation generale => OK
375
+    if (!$type) {
376
+        return true;
377
+    }
378
+
379
+    include_spip('base/objets');
380
+    $infos = lister_tables_objets_sql(table_objet_sql($type));
381
+    if (isset($infos['statut'])) {
382
+        foreach ($infos['statut'] as $c) {
383
+            if (isset($c['publie'])) {
384
+                if (!isset($c['previsu'])) {
385
+                    return false;
386
+                } // pas de previsu definie => NIET
387
+                $champ = $c['champ'];
388
+                if (!isset($opt[$champ])) {
389
+                    return false;
390
+                } // pas de champ passe a la demande => NIET
391
+                $previsu = explode(',', $c['previsu']);
392
+                // regarder si ce statut est autorise pour l'auteur
393
+                if (in_array($opt[$champ] . '/auteur', $previsu)) {
394
+                    // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
395
+                    // sinon l’auteur en session
396
+                    include_spip('inc/securiser_action');
397
+                    if ($desc = decrire_token_previsu()) {
398
+                        $id_auteur = $desc['id_auteur'];
399
+                    } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
400
+                        $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']);
401
+                    } else {
402
+                        $id_auteur = null;
403
+                    }
404
+
405
+                    if (!$id_auteur) {
406
+                        return false;
407
+                    } elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) {
408
+                        // dans ce cas (admin en general), pas de filtrage sur ce statut
409
+                    } elseif (
410
+                        !sql_countsel(
411
+                            'spip_auteurs_liens',
412
+                            'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id)
413
+                        )
414
+                    ) {
415
+                        return false;
416
+                    } // pas auteur de cet objet => NIET
417
+                } elseif (!in_array($opt[$champ], $previsu)) {
418
+                    // le statut n'est pas dans ceux definis par la previsu => NIET
419
+                    return false;
420
+                }
421
+            }
422
+        }
423
+    }
424
+
425
+    return true;
426 426
 }
427 427
 
428 428
 /**
@@ -436,51 +436,51 @@  discard block
 block discarded – undo
436 436
  * @return bool          true s'il a le droit, false sinon
437 437
  **/
438 438
 function autoriser_changerlangue_dist($faire, $type, $id, $qui, $opt) {
439
-	$multi_objets = explode(',', lire_config('multi_objets'));
440
-	$gerer_trad_objets = explode(',', lire_config('gerer_trad_objets'));
441
-	$table = table_objet_sql($type);
442
-	if (
443
-		in_array($table, $multi_objets)
444
-		or in_array($table, $gerer_trad_objets)
445
-	) { // affichage du formulaire si la configuration l'accepte
446
-		$multi_secteurs = lire_config('multi_secteurs');
447
-		$champs = objet_info($type, 'field');
448
-		if (
449
-			$multi_secteurs == 'oui'
450
-			and array_key_exists('id_rubrique', $champs)
451
-		) {
452
-			// multilinguisme par secteur et objet rattaché à une rubrique
453
-			$primary = id_table_objet($type);
454
-			if ($table != 'spip_rubriques') {
455
-				$id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id));
456
-			} else {
457
-				$id_rubrique = $id;
458
-			}
459
-			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
460
-			if (!$id_secteur > 0) {
461
-				$id_secteur = $id_rubrique;
462
-			}
463
-			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur));
464
-			$langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id));
465
-			if ($langue_secteur != $langue_objet) {
466
-				// configuration incohérente, on laisse l'utilisateur corriger la situation
467
-				return true;
468
-			}
469
-			if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
470
-				return false;
471
-			} else {
472
-				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id));
473
-				if ($id_parent != 0) {
474
-					// sous-rubriques : pas de choix de langue
475
-					return false;
476
-				}
477
-			}
478
-		}
479
-	} else {
480
-		return false;
481
-	}
482
-
483
-	return autoriser('modifier', $type, $id, $qui, $opt);
439
+    $multi_objets = explode(',', lire_config('multi_objets'));
440
+    $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets'));
441
+    $table = table_objet_sql($type);
442
+    if (
443
+        in_array($table, $multi_objets)
444
+        or in_array($table, $gerer_trad_objets)
445
+    ) { // affichage du formulaire si la configuration l'accepte
446
+        $multi_secteurs = lire_config('multi_secteurs');
447
+        $champs = objet_info($type, 'field');
448
+        if (
449
+            $multi_secteurs == 'oui'
450
+            and array_key_exists('id_rubrique', $champs)
451
+        ) {
452
+            // multilinguisme par secteur et objet rattaché à une rubrique
453
+            $primary = id_table_objet($type);
454
+            if ($table != 'spip_rubriques') {
455
+                $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id));
456
+            } else {
457
+                $id_rubrique = $id;
458
+            }
459
+            $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
460
+            if (!$id_secteur > 0) {
461
+                $id_secteur = $id_rubrique;
462
+            }
463
+            $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur));
464
+            $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id));
465
+            if ($langue_secteur != $langue_objet) {
466
+                // configuration incohérente, on laisse l'utilisateur corriger la situation
467
+                return true;
468
+            }
469
+            if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
470
+                return false;
471
+            } else {
472
+                $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id));
473
+                if ($id_parent != 0) {
474
+                    // sous-rubriques : pas de choix de langue
475
+                    return false;
476
+                }
477
+            }
478
+        }
479
+    } else {
480
+        return false;
481
+    }
482
+
483
+    return autoriser('modifier', $type, $id, $qui, $opt);
484 484
 }
485 485
 
486 486
 /**
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
  * @return bool          true s'il a le droit, false sinon
495 495
  **/
496 496
 function autoriser_changertraduction_dist($faire, $type, $id, $qui, $opt) {
497
-	return autoriser('modifier', $type, $id, $qui, $opt);
497
+    return autoriser('modifier', $type, $id, $qui, $opt);
498 498
 }
499 499
 
500 500
 /**
@@ -508,41 +508,41 @@  discard block
 block discarded – undo
508 508
  * @return bool          true s'il a le droit, false sinon
509 509
  **/
510 510
 function autoriser_dater_dist($faire, $type, $id, $qui, $opt) {
511
-	$table = table_objet($type);
512
-	$trouver_table = charger_fonction('trouver_table', 'base');
513
-	$desc = $trouver_table($table);
514
-	if (!$desc) {
515
-		return false;
516
-	}
517
-
518
-	if (!isset($opt['statut'])) {
519
-		if (isset($desc['field']['statut'])) {
520
-			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id));
521
-		} else {
522
-			$statut = 'publie';
523
-		} // pas de statut => publie
524
-	} else {
525
-		$statut = $opt['statut'];
526
-	}
527
-
528
-	// Liste des statuts publiés pour cet objet
529
-	if (isset($desc['statut'][0]['publie'])) {
530
-		$statuts_publies = explode(',', $desc['statut'][0]['publie']);
531
-	}
532
-	// Sinon en dur le statut "publie"
533
-	else {
534
-		$statuts_publies = ['publie'];
535
-	}
536
-
537
-	if (
538
-		in_array($statut, $statuts_publies)
539
-		// Ou cas particulier géré en dur ici pour les articles
540
-		or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')
541
-	) {
542
-		return autoriser('modifier', $type, $id);
543
-	}
544
-
545
-	return false;
511
+    $table = table_objet($type);
512
+    $trouver_table = charger_fonction('trouver_table', 'base');
513
+    $desc = $trouver_table($table);
514
+    if (!$desc) {
515
+        return false;
516
+    }
517
+
518
+    if (!isset($opt['statut'])) {
519
+        if (isset($desc['field']['statut'])) {
520
+            $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id));
521
+        } else {
522
+            $statut = 'publie';
523
+        } // pas de statut => publie
524
+    } else {
525
+        $statut = $opt['statut'];
526
+    }
527
+
528
+    // Liste des statuts publiés pour cet objet
529
+    if (isset($desc['statut'][0]['publie'])) {
530
+        $statuts_publies = explode(',', $desc['statut'][0]['publie']);
531
+    }
532
+    // Sinon en dur le statut "publie"
533
+    else {
534
+        $statuts_publies = ['publie'];
535
+    }
536
+
537
+    if (
538
+        in_array($statut, $statuts_publies)
539
+        // Ou cas particulier géré en dur ici pour les articles
540
+        or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')
541
+    ) {
542
+        return autoriser('modifier', $type, $id);
543
+    }
544
+
545
+    return false;
546 546
 }
547 547
 
548 548
 /**
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
  * @return bool          true s'il a le droit, false sinon
560 560
  **/
561 561
 function autoriser_instituer_dist($faire, $type, $id, $qui, $opt) {
562
-	return autoriser('modifier', $type, $id, $qui, $opt);
562
+    return autoriser('modifier', $type, $id, $qui, $opt);
563 563
 }
564 564
 
565 565
 /**
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
  * @return bool          true s'il a le droit, false sinon
576 576
  **/
577 577
 function autoriser_rubrique_publierdans_dist($faire, $type, $id, $qui, $opt) {
578
-	return
579
-		($qui['statut'] == '0minirezo')
580
-		and (
581
-			!$qui['restreint'] or !$id
582
-			or in_array($id, $qui['restreint'])
583
-		);
578
+    return
579
+        ($qui['statut'] == '0minirezo')
580
+        and (
581
+            !$qui['restreint'] or !$id
582
+            or in_array($id, $qui['restreint'])
583
+        );
584 584
 }
585 585
 
586 586
 /**
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
  * @return bool          true s'il a le droit, false sinon
597 597
  **/
598 598
 function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) {
599
-	if (!empty($opt['id_parent'])) {
600
-		return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
601
-	}
602
-	else {
603
-		return autoriser('defaut', null, null, $qui, $opt);
604
-	}
599
+    if (!empty($opt['id_parent'])) {
600
+        return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
601
+    }
602
+    else {
603
+        return autoriser('defaut', null, null, $qui, $opt);
604
+    }
605 605
 }
606 606
 
607 607
 /**
@@ -617,10 +617,10 @@  discard block
 block discarded – undo
617 617
  * @return bool          true s'il a le droit, false sinon
618 618
  **/
619 619
 function autoriser_rubrique_creerrubriquedans_dist($faire, $type, $id, $qui, $opt) {
620
-	return
621
-		($id or ($qui['statut'] == '0minirezo' and !$qui['restreint']))
622
-		and autoriser('voir', 'rubrique', $id)
623
-		and autoriser('publierdans', 'rubrique', $id);
620
+    return
621
+        ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint']))
622
+        and autoriser('voir', 'rubrique', $id)
623
+        and autoriser('publierdans', 'rubrique', $id);
624 624
 }
625 625
 
626 626
 /**
@@ -636,10 +636,10 @@  discard block
 block discarded – undo
636 636
  * @return bool          true s'il a le droit, false sinon
637 637
  **/
638 638
 function autoriser_rubrique_creerarticledans_dist($faire, $type, $id, $qui, $opt) {
639
-	return
640
-		$id
641
-		and autoriser('voir', 'rubrique', $id)
642
-		and autoriser('creer', 'article');
639
+    return
640
+        $id
641
+        and autoriser('voir', 'rubrique', $id)
642
+        and autoriser('creer', 'article');
643 643
 }
644 644
 
645 645
 
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
  * @return bool          true s'il a le droit, false sinon
657 657
  **/
658 658
 function autoriser_rubrique_modifier_dist($faire, $type, $id, $qui, $opt) {
659
-	return
660
-		autoriser('publierdans', 'rubrique', $id, $qui, $opt);
659
+    return
660
+        autoriser('publierdans', 'rubrique', $id, $qui, $opt);
661 661
 }
662 662
 
663 663
 /**
@@ -673,29 +673,29 @@  discard block
 block discarded – undo
673 673
  * @return bool          true s'il a le droit, false sinon
674 674
  **/
675 675
 function autoriser_rubrique_supprimer_dist($faire, $type, $id, $qui, $opt) {
676
-	if (!$id = intval($id)) {
677
-		return false;
678
-	}
676
+    if (!$id = intval($id)) {
677
+        return false;
678
+    }
679 679
 
680
-	if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) {
681
-		return false;
682
-	}
680
+    if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) {
681
+        return false;
682
+    }
683 683
 
684
-	if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) {
685
-		return false;
686
-	}
684
+    if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) {
685
+        return false;
686
+    }
687 687
 
688
-	$compte = pipeline(
689
-		'objet_compte_enfants',
690
-		['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []]
691
-	);
692
-	foreach ($compte as $objet => $n) {
693
-		if ($n) {
694
-			return false;
695
-		}
696
-	}
688
+    $compte = pipeline(
689
+        'objet_compte_enfants',
690
+        ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []]
691
+    );
692
+    foreach ($compte as $objet => $n) {
693
+        if ($n) {
694
+            return false;
695
+        }
696
+    }
697 697
 
698
-	return autoriser('modifier', 'rubrique', $id);
698
+    return autoriser('modifier', 'rubrique', $id);
699 699
 }
700 700
 
701 701
 
@@ -713,20 +713,20 @@  discard block
 block discarded – undo
713 713
  * @return bool          true s'il a le droit, false sinon
714 714
  **/
715 715
 function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) {
716
-	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
716
+    $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
717 717
 
718
-	return
719
-		$r
720
-		and
721
-		(
722
-			autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
723
-			or (
724
-				(!isset($opt['statut']) or $opt['statut'] !== 'publie')
725
-				and in_array($qui['statut'], ['0minirezo', '1comite'])
726
-				and in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
727
-				and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
728
-			)
729
-		);
718
+    return
719
+        $r
720
+        and
721
+        (
722
+            autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
723
+            or (
724
+                (!isset($opt['statut']) or $opt['statut'] !== 'publie')
725
+                and in_array($qui['statut'], ['0minirezo', '1comite'])
726
+                and in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
727
+                and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
728
+            )
729
+        );
730 730
 }
731 731
 
732 732
 /**
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
  * @return bool          true s'il a le droit, false sinon
743 743
  **/
744 744
 function autoriser_article_creer_dist($faire, $type, $id, $qui, $opt) {
745
-	if (!empty($opt['id_parent'])) {
746
-		// creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
747
-		return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
748
-	}
749
-	else {
750
-		return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite']));
751
-	}
745
+    if (!empty($opt['id_parent'])) {
746
+        // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
747
+        return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
748
+    }
749
+    else {
750
+        return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite']));
751
+    }
752 752
 }
753 753
 
754 754
 /**
@@ -768,28 +768,28 @@  discard block
 block discarded – undo
768 768
  * @return bool          true s'il a le droit, false sinon
769 769
  */
770 770
 function autoriser_article_voir_dist($faire, $type, $id, $qui, $opt) {
771
-	if ($qui['statut'] == '0minirezo') {
772
-		return true;
773
-	}
774
-	// cas des articles : depend du statut de l'article et de l'auteur
775
-	if (isset($opt['statut'])) {
776
-		$statut = $opt['statut'];
777
-	} else {
778
-		if (!$id) {
779
-			return false;
780
-		}
781
-		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id));
782
-	}
783
-
784
-	return
785
-		// si on est pas auteur de l'article,
786
-		// seuls les propose et publies sont visibles
787
-		in_array($statut, ['prop', 'publie'])
788
-		// sinon si on est auteur, on a le droit de le voir, evidemment !
789
-		or
790
-		($id
791
-			and $qui['id_auteur']
792
-			and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']));
771
+    if ($qui['statut'] == '0minirezo') {
772
+        return true;
773
+    }
774
+    // cas des articles : depend du statut de l'article et de l'auteur
775
+    if (isset($opt['statut'])) {
776
+        $statut = $opt['statut'];
777
+    } else {
778
+        if (!$id) {
779
+            return false;
780
+        }
781
+        $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id));
782
+    }
783
+
784
+    return
785
+        // si on est pas auteur de l'article,
786
+        // seuls les propose et publies sont visibles
787
+        in_array($statut, ['prop', 'publie'])
788
+        // sinon si on est auteur, on a le droit de le voir, evidemment !
789
+        or
790
+        ($id
791
+            and $qui['id_auteur']
792
+            and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']));
793 793
 }
794 794
 
795 795
 
@@ -806,24 +806,24 @@  discard block
 block discarded – undo
806 806
  * @return bool          true s'il a le droit, false sinon
807 807
  **/
808 808
 function autoriser_voir_dist($faire, $type, $id, $qui, $opt) {
809
-	# securite, mais on aurait pas du arriver ici !
810
-	if (
811
-		function_exists($f = 'autoriser_' . $type . '_voir')
812
-		or function_exists($f = 'autoriser_' . $type . '_voir_dist')
813
-	) {
814
-		return $f($faire, $type, $id, $qui, $opt);
815
-	}
809
+    # securite, mais on aurait pas du arriver ici !
810
+    if (
811
+        function_exists($f = 'autoriser_' . $type . '_voir')
812
+        or function_exists($f = 'autoriser_' . $type . '_voir_dist')
813
+    ) {
814
+        return $f($faire, $type, $id, $qui, $opt);
815
+    }
816 816
 
817
-	if ($qui['statut'] == '0minirezo') {
818
-		return true;
819
-	}
820
-	// admins et redacteurs peuvent voir un auteur
821
-	if ($type == 'auteur') {
822
-		return in_array($qui['statut'], ['0minirezo', '1comite']);
823
-	}
824
-	// sinon par defaut tout est visible
825
-	// sauf cas particuliers traites separemment (ie article)
826
-	return true;
817
+    if ($qui['statut'] == '0minirezo') {
818
+        return true;
819
+    }
820
+    // admins et redacteurs peuvent voir un auteur
821
+    if ($type == 'auteur') {
822
+        return in_array($qui['statut'], ['0minirezo', '1comite']);
823
+    }
824
+    // sinon par defaut tout est visible
825
+    // sauf cas particuliers traites separemment (ie article)
826
+    return true;
827 827
 }
828 828
 
829 829
 
@@ -844,12 +844,12 @@  discard block
 block discarded – undo
844 844
  * @return bool          true s'il a le droit, false sinon
845 845
  **/
846 846
 function autoriser_webmestre_dist($faire, $type, $id, $qui, $opt) {
847
-	return
848
-		(defined('_ID_WEBMESTRES') ?
849
-			in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES))
850
-			: $qui['webmestre'] == 'oui')
851
-		and $qui['statut'] == '0minirezo'
852
-		and !$qui['restreint'];
847
+    return
848
+        (defined('_ID_WEBMESTRES') ?
849
+            in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES))
850
+            : $qui['webmestre'] == 'oui')
851
+        and $qui['statut'] == '0minirezo'
852
+        and !$qui['restreint'];
853 853
 }
854 854
 
855 855
 /**
@@ -865,9 +865,9 @@  discard block
 block discarded – undo
865 865
  * @return bool          true s'il a le droit, false sinon
866 866
  **/
867 867
 function autoriser_configurer_dist($faire, $type, $id, $qui, $opt) {
868
-	return
869
-		$qui['statut'] == '0minirezo'
870
-		and !$qui['restreint'];
868
+    return
869
+        $qui['statut'] == '0minirezo'
870
+        and !$qui['restreint'];
871 871
 }
872 872
 
873 873
 /**
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
  * @return bool          true s'il a le droit, false sinon
884 884
  **/
885 885
 function autoriser_sauvegarder_dist($faire, $type, $id, $qui, $opt) {
886
-	return
887
-		$qui['statut'] == '0minirezo';
886
+    return
887
+        $qui['statut'] == '0minirezo';
888 888
 }
889 889
 
890 890
 /**
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
  * @return bool          true s'il a le droit, false sinon
901 901
  **/
902 902
 function autoriser_detruire_dist($faire, $type, $id, $qui, $opt) {
903
-	return
904
-		autoriser('webmestre', null, null, $qui, $opt);
903
+    return
904
+        autoriser('webmestre', null, null, $qui, $opt);
905 905
 }
906 906
 
907 907
 /**
@@ -918,21 +918,21 @@  discard block
 block discarded – undo
918 918
  * @return bool          true s'il a le droit, false sinon
919 919
  **/
920 920
 function autoriser_auteur_previsualiser_dist($faire, $type, $id, $qui, $opt) {
921
-	// les admins peuvent "previsualiser" une page auteur
922
-	if (
923
-		$qui['statut'] == '0minirezo'
924
-		and !$qui['restreint']
925
-	) {
926
-		return true;
927
-	}
928
-	// "Voir en ligne" si l'auteur a un article publie
929
-	$n = sql_fetsel(
930
-		'A.id_article',
931
-		'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
932
-		"A.statut='publie' AND L.id_auteur=" . sql_quote($id)
933
-	);
921
+    // les admins peuvent "previsualiser" une page auteur
922
+    if (
923
+        $qui['statut'] == '0minirezo'
924
+        and !$qui['restreint']
925
+    ) {
926
+        return true;
927
+    }
928
+    // "Voir en ligne" si l'auteur a un article publie
929
+    $n = sql_fetsel(
930
+        'A.id_article',
931
+        'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
932
+        "A.statut='publie' AND L.id_auteur=" . sql_quote($id)
933
+    );
934 934
 
935
-	return $n ? true : false;
935
+    return $n ? true : false;
936 936
 }
937 937
 
938 938
 
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
  * @return bool          true s'il a le droit, false sinon
961 961
  **/
962 962
 function autoriser_auteur_creer_dist($faire, $type, $id, $qui, $opt) {
963
-	return ($qui['statut'] == '0minirezo');
963
+    return ($qui['statut'] == '0minirezo');
964 964
 }
965 965
 
966 966
 
@@ -980,73 +980,73 @@  discard block
 block discarded – undo
980 980
  **/
981 981
 function autoriser_auteur_modifier_dist($faire, $type, $id, $qui, $opt) {
982 982
 
983
-	// Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login
984
-	// la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca
985
-	if (!in_array($qui['statut'], ['0minirezo'])) {
986
-		if (
987
-			$id == $qui['id_auteur']
988
-			&& empty($opt['statut'])
989
-			&& empty($opt['webmestre'])
990
-			&& empty($opt['restreintes'])
991
-			&& empty($opt['login'])
992
-		) {
993
-			return true;
994
-		}
995
-		return false;
996
-	}
997
-
998
-	// Un admin restreint peut modifier/creer un auteur non-admin mais il
999
-	// n'a le droit ni de le promouvoir admin, ni de changer les rubriques
1000
-	if ($qui['restreint']) {
1001
-		if (isset($opt['webmestre']) and $opt['webmestre']) {
1002
-			return false;
1003
-		} elseif (
1004
-			(isset($opt['statut']) and ($opt['statut'] == '0minirezo'))
1005
-			or (isset($opt['restreintes']) and $opt['restreintes'])
1006
-		) {
1007
-			return false;
1008
-		} else {
1009
-			if ($id == $qui['id_auteur']) {
1010
-				if (isset($opt['statut']) and $opt['statut']) {
1011
-					return false;
1012
-				} else {
1013
-					return true;
1014
-				}
1015
-			} else {
1016
-				if ($id_auteur = intval($id)) {
1017
-					$t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur");
1018
-					if ($t and $t['statut'] != '0minirezo') {
1019
-						return true;
1020
-					} else {
1021
-						return false;
1022
-					}
1023
-				} // id = 0 => creation
1024
-				else {
1025
-					return true;
1026
-				}
1027
-			}
1028
-		}
1029
-	}
1030
-
1031
-	// Un admin complet fait ce qu'il veut
1032
-	// sauf se degrader
1033
-	if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) {
1034
-		return false;
1035
-	} elseif (
1036
-		isset($opt['webmestre'])
1037
-				and $opt['webmestre']
1038
-				and (defined('_ID_WEBMESTRES')
1039
-				or !autoriser('webmestre'))
1040
-	) {
1041
-		// et toucher au statut webmestre si il ne l'est pas lui meme
1042
-		// ou si les webmestres sont fixes par constante (securite)
1043
-		return false;
1044
-	} // et modifier un webmestre si il ne l'est pas lui meme
1045
-	elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) {
1046
-		return false;
1047
-	} else {
1048
-		return true;
1049
-	}
983
+    // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login
984
+    // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca
985
+    if (!in_array($qui['statut'], ['0minirezo'])) {
986
+        if (
987
+            $id == $qui['id_auteur']
988
+            && empty($opt['statut'])
989
+            && empty($opt['webmestre'])
990
+            && empty($opt['restreintes'])
991
+            && empty($opt['login'])
992
+        ) {
993
+            return true;
994
+        }
995
+        return false;
996
+    }
997
+
998
+    // Un admin restreint peut modifier/creer un auteur non-admin mais il
999
+    // n'a le droit ni de le promouvoir admin, ni de changer les rubriques
1000
+    if ($qui['restreint']) {
1001
+        if (isset($opt['webmestre']) and $opt['webmestre']) {
1002
+            return false;
1003
+        } elseif (
1004
+            (isset($opt['statut']) and ($opt['statut'] == '0minirezo'))
1005
+            or (isset($opt['restreintes']) and $opt['restreintes'])
1006
+        ) {
1007
+            return false;
1008
+        } else {
1009
+            if ($id == $qui['id_auteur']) {
1010
+                if (isset($opt['statut']) and $opt['statut']) {
1011
+                    return false;
1012
+                } else {
1013
+                    return true;
1014
+                }
1015
+            } else {
1016
+                if ($id_auteur = intval($id)) {
1017
+                    $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur");
1018
+                    if ($t and $t['statut'] != '0minirezo') {
1019
+                        return true;
1020
+                    } else {
1021
+                        return false;
1022
+                    }
1023
+                } // id = 0 => creation
1024
+                else {
1025
+                    return true;
1026
+                }
1027
+            }
1028
+        }
1029
+    }
1030
+
1031
+    // Un admin complet fait ce qu'il veut
1032
+    // sauf se degrader
1033
+    if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) {
1034
+        return false;
1035
+    } elseif (
1036
+        isset($opt['webmestre'])
1037
+                and $opt['webmestre']
1038
+                and (defined('_ID_WEBMESTRES')
1039
+                or !autoriser('webmestre'))
1040
+    ) {
1041
+        // et toucher au statut webmestre si il ne l'est pas lui meme
1042
+        // ou si les webmestres sont fixes par constante (securite)
1043
+        return false;
1044
+    } // et modifier un webmestre si il ne l'est pas lui meme
1045
+    elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) {
1046
+        return false;
1047
+    } else {
1048
+        return true;
1049
+    }
1050 1050
 }
1051 1051
 
1052 1052
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
  * @return bool          true s'il a le droit, false sinon
1064 1064
  **/
1065 1065
 function autoriser_associerauteurs_dist($faire, $type, $id, $qui, $opt) {
1066
-	return autoriser('modifier', $type, $id, $qui, $opt);
1066
+    return autoriser('modifier', $type, $id, $qui, $opt);
1067 1067
 }
1068 1068
 
1069 1069
 
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
  * @return bool          true s'il a le droit, false sinon
1081 1081
  **/
1082 1082
 function autoriser_chargerftp_dist($faire, $type, $id, $qui, $opt) {
1083
-	return $qui['statut'] == '0minirezo';
1083
+    return $qui['statut'] == '0minirezo';
1084 1084
 }
1085 1085
 
1086 1086
 /**
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
  * @return bool          true s'il a le droit, false sinon
1097 1097
  **/
1098 1098
 function autoriser_debug_dist($faire, $type, $id, $qui, $opt) {
1099
-	return $qui['statut'] == '0minirezo';
1099
+    return $qui['statut'] == '0minirezo';
1100 1100
 }
1101 1101
 
1102 1102
 /**
@@ -1113,54 +1113,54 @@  discard block
 block discarded – undo
1113 1113
  * @return array          Liste des rubriques
1114 1114
  **/
1115 1115
 function liste_rubriques_auteur($id_auteur, $raz = false) {
1116
-	static $restreint = [];
1117
-
1118
-	if (!$id_auteur = intval($id_auteur)) {
1119
-		return [];
1120
-	}
1121
-	if ($raz) {
1122
-		unset($restreint[$id_auteur]);
1123
-	} elseif (isset($restreint[$id_auteur])) {
1124
-		return $restreint[$id_auteur];
1125
-	}
1126
-
1127
-	$rubriques = [];
1128
-	if (
1129
-		(!isset($GLOBALS['meta']['version_installee'])
1130
-		or $GLOBALS['meta']['version_installee'] > 16428)
1131
-		and $r = sql_allfetsel(
1132
-			'id_objet',
1133
-			'spip_auteurs_liens',
1134
-			'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0"
1135
-		)
1136
-		and count($r)
1137
-	) {
1138
-		$r = array_column($r, 'id_objet');
1139
-
1140
-		// recuperer toute la branche, au format chaine enumeration
1141
-		include_spip('inc/rubriques');
1142
-		$r = calcul_branche_in($r);
1143
-		$r = explode(',', $r);
1144
-
1145
-		// passer les rubriques en index, elimine les doublons
1146
-		$r = array_flip($r);
1147
-		// recuperer les index seuls
1148
-		$r = array_keys($r);
1149
-		// combiner pour avoir un tableau id_rubrique=>id_rubrique
1150
-		// est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
1151
-		$rubriques = array_combine($r, $r);
1152
-	}
1153
-
1154
-	// Affecter l'auteur session le cas echeant
1155
-	if (
1156
-		isset($GLOBALS['visiteur_session']['id_auteur'])
1157
-		and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
1158
-	) {
1159
-		$GLOBALS['visiteur_session']['restreint'] = $rubriques;
1160
-	}
1161
-
1162
-
1163
-	return $restreint[$id_auteur] = $rubriques;
1116
+    static $restreint = [];
1117
+
1118
+    if (!$id_auteur = intval($id_auteur)) {
1119
+        return [];
1120
+    }
1121
+    if ($raz) {
1122
+        unset($restreint[$id_auteur]);
1123
+    } elseif (isset($restreint[$id_auteur])) {
1124
+        return $restreint[$id_auteur];
1125
+    }
1126
+
1127
+    $rubriques = [];
1128
+    if (
1129
+        (!isset($GLOBALS['meta']['version_installee'])
1130
+        or $GLOBALS['meta']['version_installee'] > 16428)
1131
+        and $r = sql_allfetsel(
1132
+            'id_objet',
1133
+            'spip_auteurs_liens',
1134
+            'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0"
1135
+        )
1136
+        and count($r)
1137
+    ) {
1138
+        $r = array_column($r, 'id_objet');
1139
+
1140
+        // recuperer toute la branche, au format chaine enumeration
1141
+        include_spip('inc/rubriques');
1142
+        $r = calcul_branche_in($r);
1143
+        $r = explode(',', $r);
1144
+
1145
+        // passer les rubriques en index, elimine les doublons
1146
+        $r = array_flip($r);
1147
+        // recuperer les index seuls
1148
+        $r = array_keys($r);
1149
+        // combiner pour avoir un tableau id_rubrique=>id_rubrique
1150
+        // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
1151
+        $rubriques = array_combine($r, $r);
1152
+    }
1153
+
1154
+    // Affecter l'auteur session le cas echeant
1155
+    if (
1156
+        isset($GLOBALS['visiteur_session']['id_auteur'])
1157
+        and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
1158
+    ) {
1159
+        $GLOBALS['visiteur_session']['restreint'] = $rubriques;
1160
+    }
1161
+
1162
+
1163
+    return $restreint[$id_auteur] = $rubriques;
1164 1164
 }
1165 1165
 
1166 1166
 /**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
  * @return bool          true s'il a le droit, false sinon
1177 1177
  **/
1178 1178
 function autoriser_rubrique_previsualiser_dist($faire, $type, $id, $qui, $opt) {
1179
-	return autoriser('previsualiser');
1179
+    return autoriser('previsualiser');
1180 1180
 }
1181 1181
 
1182 1182
 /**
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
  * @return bool          true s'il a le droit, false sinon
1193 1193
  **/
1194 1194
 function autoriser_rubrique_iconifier_dist($faire, $type, $id, $qui, $opt) {
1195
-	return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
1195
+    return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
1196 1196
 }
1197 1197
 
1198 1198
 /**
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
  * @return bool          true s'il a le droit, false sinon
1209 1209
  **/
1210 1210
 function autoriser_auteur_iconifier_dist($faire, $type, $id, $qui, $opt) {
1211
-	return (($id == $qui['id_auteur']) or
1212
-		(($qui['statut'] == '0minirezo') and !$qui['restreint']));
1211
+    return (($id == $qui['id_auteur']) or
1212
+        (($qui['statut'] == '0minirezo') and !$qui['restreint']));
1213 1213
 }
1214 1214
 
1215 1215
 /**
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
  * @return bool          true s'il a le droit, false sinon
1226 1226
  **/
1227 1227
 function autoriser_iconifier_dist($faire, $type, $id, $qui, $opt) {
1228
-	// par defaut, on a le droit d'iconifier si on a le droit de modifier
1229
-	return autoriser('modifier', $type, $id, $qui, $opt);
1228
+    // par defaut, on a le droit d'iconifier si on a le droit de modifier
1229
+    return autoriser('modifier', $type, $id, $qui, $opt);
1230 1230
 }
1231 1231
 
1232 1232
 
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
  * @return bool          true
1245 1245
  **/
1246 1246
 function autoriser_ok_dist($faire, $type, $id, $qui, $opt) {
1247
-	return true;
1247
+    return true;
1248 1248
 }
1249 1249
 
1250 1250
 /**
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
  * @return bool          false
1262 1262
  **/
1263 1263
 function autoriser_niet_dist($faire, $type, $id, $qui, $opt) {
1264
-	return false;
1264
+    return false;
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1277,11 +1277,11 @@  discard block
 block discarded – undo
1277 1277
  * @return bool          false
1278 1278
  **/
1279 1279
 function autoriser_base_reparer_dist($faire, $type, $id, $qui, $opt) {
1280
-	if (!autoriser('detruire') or _request('reinstall')) {
1281
-		return false;
1282
-	}
1280
+    if (!autoriser('detruire') or _request('reinstall')) {
1281
+        return false;
1282
+    }
1283 1283
 
1284
-	return true;
1284
+    return true;
1285 1285
 }
1286 1286
 
1287 1287
 /**
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
  * @return bool          true s'il a le droit, false sinon
1298 1298
  **/
1299 1299
 function autoriser_infosperso_dist($faire, $type, $id, $qui, $opt) {
1300
-	return true;
1300
+    return true;
1301 1301
 }
1302 1302
 
1303 1303
 /**
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
  * @return bool          true s'il a le droit, false sinon
1314 1314
  **/
1315 1315
 function autoriser_langage_configurer_dist($faire, $type, $id, $qui, $opt) {
1316
-	return true;
1316
+    return true;
1317 1317
 }
1318 1318
 
1319 1319
 /**
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
  * @return bool          true s'il a le droit, false sinon
1330 1330
  **/
1331 1331
 function autoriser_configurerlangage_dist($faire, $type, $id, $qui, $opt) {
1332
-	return autoriser('configurer', '_langage', $id, $qui, $opt);
1332
+    return autoriser('configurer', '_langage', $id, $qui, $opt);
1333 1333
 }
1334 1334
 
1335 1335
 /**
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
  * @return bool          true s'il a le droit, false sinon
1346 1346
  **/
1347 1347
 function autoriser_preferences_configurer_dist($faire, $type, $id, $qui, $opt) {
1348
-	return true;
1348
+    return true;
1349 1349
 }
1350 1350
 
1351 1351
 /**
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
  * @return bool          true s'il a le droit, false sinon
1362 1362
  **/
1363 1363
 function autoriser_configurerpreferences_dist($faire, $type, $id, $qui, $opt) {
1364
-	return autoriser('configurer', '_preferences', $id, $qui, $opt);
1364
+    return autoriser('configurer', '_preferences', $id, $qui, $opt);
1365 1365
 }
1366 1366
 
1367 1367
 /**
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
  * @return bool          true s'il a le droit, false sinon
1378 1378
  **/
1379 1379
 function autoriser_menudeveloppement_menugrandeentree_dist($faire, $type, $id, $qui, $opt) {
1380
-	return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev'])
1381
-		and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui');
1380
+    return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev'])
1381
+        and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui');
1382 1382
 }
1383 1383
 
1384 1384
 /**
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
  * @return bool          true s'il a le droit, false sinon
1396 1396
  **/
1397 1397
 function autoriser_menugrandeentree_dist($faire, $type, $id, $qui, $opt) {
1398
-	return true;
1398
+    return true;
1399 1399
 }
1400 1400
 
1401 1401
 /**
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
  * @return bool          true s'il a le droit, false sinon
1412 1412
  **/
1413 1413
 function autoriser_auteurs_voir_dist($faire, $type, $id, $qui, $opt) {
1414
-	return true;
1414
+    return true;
1415 1415
 }
1416 1416
 
1417 1417
 /**
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
  * @return bool          true s'il a le droit, false sinon
1428 1428
  **/
1429 1429
 function autoriser_auteurs_menu_dist($faire, $type, $id, $qui, $opt) {
1430
-	return autoriser('voir', '_auteurs', $id, $qui, $opt);
1430
+    return autoriser('voir', '_auteurs', $id, $qui, $opt);
1431 1431
 }
1432 1432
 
1433 1433
 /**
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
  * @return bool          true s'il a le droit, false sinon
1444 1444
  **/
1445 1445
 function autoriser_articles_voir_dist($faire, $type, $id, $qui, $opt) {
1446
-	return true;
1446
+    return true;
1447 1447
 }
1448 1448
 
1449 1449
 /**
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
  * @return bool          true s'il a le droit, false sinon
1460 1460
  **/
1461 1461
 function autoriser_articles_menu_dist($faire, $type, $id, $qui, $opt) {
1462
-	return autoriser('voir', '_articles', $id, $qui, $opt);
1462
+    return autoriser('voir', '_articles', $id, $qui, $opt);
1463 1463
 }
1464 1464
 
1465 1465
 /**
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
  * @return bool          true s'il a le droit, false sinon
1476 1476
  **/
1477 1477
 function autoriser_rubriques_voir_dist($faire, $type, $id, $qui, $opt) {
1478
-	return true;
1478
+    return true;
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
  * @return bool          true s'il a le droit, false sinon
1492 1492
  **/
1493 1493
 function autoriser_rubriques_menu_dist($faire, $type, $id, $qui, $opt) {
1494
-	return autoriser('voir', '_rubriques', $id, $qui, $opt);
1494
+    return autoriser('voir', '_rubriques', $id, $qui, $opt);
1495 1495
 }
1496 1496
 
1497 1497
 /**
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
  * @return bool          true s'il a le droit, false sinon
1508 1508
  **/
1509 1509
 function autoriser_articlecreer_menu_dist($faire, $type, $id, $qui, $opt) {
1510
-	return verifier_table_non_vide();
1510
+    return verifier_table_non_vide();
1511 1511
 }
1512 1512
 
1513 1513
 
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
  * @return bool          true s'il a le droit, false sinon
1527 1527
  **/
1528 1528
 function autoriser_auteurcreer_menu_dist($faire, $type, $id, $qui, $opt) {
1529
-	return autoriser('creer', 'auteur', $id, $qui, $opt);
1529
+    return autoriser('creer', 'auteur', $id, $qui, $opt);
1530 1530
 }
1531 1531
 
1532 1532
 /**
@@ -1542,13 +1542,13 @@  discard block
 block discarded – undo
1542 1542
  * @return bool          true s'il a le droit, false sinon
1543 1543
  **/
1544 1544
 function autoriser_visiteurs_menu_dist($faire, $type, $id, $qui, $opt) {
1545
-	include_spip('base/abstract_sql');
1546
-	return
1547
-		$qui['statut'] == '0minirezo' and !$qui['restreint']
1548
-		and (
1549
-			$GLOBALS['meta']['accepter_visiteurs'] != 'non'
1550
-			or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0
1551
-		);
1545
+    include_spip('base/abstract_sql');
1546
+    return
1547
+        $qui['statut'] == '0minirezo' and !$qui['restreint']
1548
+        and (
1549
+            $GLOBALS['meta']['accepter_visiteurs'] != 'non'
1550
+            or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0
1551
+        );
1552 1552
 }
1553 1553
 
1554 1554
 /**
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
  * @return bool          true s'il a le droit, false sinon
1565 1565
  **/
1566 1566
 function autoriser_suiviedito_menu_dist($faire, $type, $id, $qui, $opt) {
1567
-	return $qui['statut'] == '0minirezo';
1567
+    return $qui['statut'] == '0minirezo';
1568 1568
 }
1569 1569
 
1570 1570
 /**
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
  * @return bool          true s'il a le droit, false sinon
1581 1581
  **/
1582 1582
 function autoriser_synchro_menu_dist($faire, $type, $id, $qui, $opt) {
1583
-	return $qui['statut'] == '0minirezo';
1583
+    return $qui['statut'] == '0minirezo';
1584 1584
 }
1585 1585
 
1586 1586
 /**
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
  * @return bool          true s'il a le droit, false sinon
1597 1597
  **/
1598 1598
 function autoriser_configurerinteractions_menu_dist($faire, $type, $id, $qui, $opt) {
1599
-	return autoriser('configurer', '_interactions', $id, $qui, $opt);
1599
+    return autoriser('configurer', '_interactions', $id, $qui, $opt);
1600 1600
 }
1601 1601
 
1602 1602
 /**
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
  * @return bool          true s'il a le droit, false sinon
1613 1613
  **/
1614 1614
 function autoriser_configurerlangue_menu_dist($faire, $type, $id, $qui, $opt) {
1615
-	return autoriser('configurer', '_langue', $id, $qui, $opt);
1615
+    return autoriser('configurer', '_langue', $id, $qui, $opt);
1616 1616
 }
1617 1617
 
1618 1618
 /**
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
  * @return bool          true s'il a le droit, false sinon
1629 1629
  **/
1630 1630
 function autoriser_configurermultilinguisme_menu_dist($faire, $type, $id, $qui, $opt) {
1631
-	return autoriser('configurer', '_multilinguisme', $id, $qui, $opt);
1631
+    return autoriser('configurer', '_multilinguisme', $id, $qui, $opt);
1632 1632
 }
1633 1633
 
1634 1634
 /**
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
  * @return bool          true s'il a le droit, false sinon
1645 1645
  **/
1646 1646
 function autoriser_configurercontenu_menu_dist($faire, $type, $id, $qui, $opt) {
1647
-	return autoriser('configurer', '_contenu', $id, $qui, $opt);
1647
+    return autoriser('configurer', '_contenu', $id, $qui, $opt);
1648 1648
 }
1649 1649
 
1650 1650
 /**
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
  * @return bool          true s'il a le droit, false sinon
1661 1661
  **/
1662 1662
 function autoriser_configureravancees_menu_dist($faire, $type, $id, $qui, $opt) {
1663
-	return autoriser('configurer', '_avancees', $id, $qui, $opt);
1663
+    return autoriser('configurer', '_avancees', $id, $qui, $opt);
1664 1664
 }
1665 1665
 
1666 1666
 /**
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
  * @return bool          true s'il a le droit, false sinon
1677 1677
  **/
1678 1678
 function autoriser_adminplugin_menu_dist($faire, $type, $id, $qui, $opt) {
1679
-	return autoriser('configurer', '_plugins', $id, $qui, $opt);
1679
+    return autoriser('configurer', '_plugins', $id, $qui, $opt);
1680 1680
 }
1681 1681
 
1682 1682
 /**
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
  * @return bool          true s'il a le droit, false sinon
1693 1693
  **/
1694 1694
 function autoriser_admintech_menu_dist($faire, $type, $id, $qui, $opt) {
1695
-	return autoriser('detruire', $type, $id, $qui, $opt);
1695
+    return autoriser('detruire', $type, $id, $qui, $opt);
1696 1696
 }
1697 1697
 
1698 1698
 /**
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
  * @return bool          true s'il a le droit, false sinon
1709 1709
  **/
1710 1710
 function autoriser_queue_purger_dist($faire, $type, $id, $qui, $opt) {
1711
-	return autoriser('webmestre');
1711
+    return autoriser('webmestre');
1712 1712
 }
1713 1713
 
1714 1714
 
@@ -1726,11 +1726,11 @@  discard block
 block discarded – undo
1726 1726
  * @return bool          true s'il a le droit, false sinon
1727 1727
  **/
1728 1728
 function autoriser_echafauder_dist($faire, $type, $id, $qui, $opt) {
1729
-	if (test_espace_prive()) {
1730
-		return intval($qui['id_auteur']) ? true : false;
1731
-	} else {
1732
-		return autoriser('webmestre', '', $id, $qui, $opt);
1733
-	}
1729
+    if (test_espace_prive()) {
1730
+        return intval($qui['id_auteur']) ? true : false;
1731
+    } else {
1732
+        return autoriser('webmestre', '', $id, $qui, $opt);
1733
+    }
1734 1734
 }
1735 1735
 
1736 1736
 
@@ -1745,27 +1745,27 @@  discard block
 block discarded – undo
1745 1745
  *     Identifiants d'auteurs
1746 1746
  */
1747 1747
 function auteurs_objet($objet, $id_objet, $cond = '') {
1748
-	$objet = objet_type($objet);
1749
-	$where = [
1750
-		'objet=' . sql_quote($objet),
1751
-		'id_objet=' . intval($id_objet)
1752
-	];
1753
-	if (!empty($cond)) {
1754
-		if (is_array($cond)) {
1755
-			$where = array_merge($where, $cond);
1756
-		} else {
1757
-			$where[] = $cond;
1758
-		}
1759
-	}
1760
-	$auteurs = sql_allfetsel(
1761
-		'id_auteur',
1762
-		'spip_auteurs_liens',
1763
-		$where
1764
-	);
1765
-	if (is_array($auteurs)) {
1766
-		return array_column($auteurs, 'id_auteur');
1767
-	}
1768
-	return [];
1748
+    $objet = objet_type($objet);
1749
+    $where = [
1750
+        'objet=' . sql_quote($objet),
1751
+        'id_objet=' . intval($id_objet)
1752
+    ];
1753
+    if (!empty($cond)) {
1754
+        if (is_array($cond)) {
1755
+            $where = array_merge($where, $cond);
1756
+        } else {
1757
+            $where[] = $cond;
1758
+        }
1759
+    }
1760
+    $auteurs = sql_allfetsel(
1761
+        'id_auteur',
1762
+        'spip_auteurs_liens',
1763
+        $where
1764
+    );
1765
+    if (is_array($auteurs)) {
1766
+        return array_column($auteurs, 'id_auteur');
1767
+    }
1768
+    return [];
1769 1769
 }
1770 1770
 
1771 1771
 /**
@@ -1780,11 +1780,11 @@  discard block
 block discarded – undo
1780 1780
  *     - false : serveur SQL indisponible
1781 1781
  */
1782 1782
 function auteurs_article($id_article, $cond = '') {
1783
-	return sql_allfetsel(
1784
-		'id_auteur',
1785
-		'spip_auteurs_liens',
1786
-		"objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '')
1787
-	);
1783
+    return sql_allfetsel(
1784
+        'id_auteur',
1785
+        'spip_auteurs_liens',
1786
+        "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '')
1787
+    );
1788 1788
 }
1789 1789
 
1790 1790
 
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
  */
1799 1799
 function acces_restreint_rubrique($id_rubrique) {
1800 1800
 
1801
-	return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique]));
1801
+    return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique]));
1802 1802
 }
1803 1803
 
1804 1804
 
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
  * @return bool             true si un parent existe
1812 1812
  */
1813 1813
 function verifier_table_non_vide($table = 'spip_rubriques') {
1814
-	static $done = [];
1815
-	if (!isset($done[$table])) {
1816
-		$done[$table] = sql_countsel($table) > 0;
1817
-	}
1814
+    static $done = [];
1815
+    if (!isset($done[$table])) {
1816
+        $done[$table] = sql_countsel($table) > 0;
1817
+    }
1818 1818
 
1819
-	return $done[$table];
1819
+    return $done[$table];
1820 1820
 }
1821 1821
 
1822 1822
 /**
@@ -1841,15 +1841,15 @@  discard block
 block discarded – undo
1841 1841
  */
1842 1842
 function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) {
1843 1843
 
1844
-	$s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1845
-	switch ($s) {
1846
-		case 'info_redacteurs':
1847
-			return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui');
1848
-		case 'info_visiteurs':
1849
-			return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo');
1850
-	}
1844
+    $s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1845
+    switch ($s) {
1846
+        case 'info_redacteurs':
1847
+            return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui');
1848
+        case 'info_visiteurs':
1849
+            return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo');
1850
+    }
1851 1851
 
1852
-	return false;
1852
+    return false;
1853 1853
 }
1854 1854
 
1855 1855
 /**
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
  * @return bool          false
1866 1866
  **/
1867 1867
 function autoriser_inscription_relancer_dist($faire, $type, $id, $qui, $opt) {
1868
-	return $qui['statut'] == '0minirezo' and !$qui['restreint'];
1868
+    return $qui['statut'] == '0minirezo' and !$qui['restreint'];
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1881,5 +1881,5 @@  discard block
 block discarded – undo
1881 1881
  * @return bool          true s'il a le droit, false sinon
1882 1882
  **/
1883 1883
 function autoriser_phpinfos_dist($faire, $type, $id, $qui, $opt) {
1884
-	return autoriser('webmestre');
1884
+    return autoriser('webmestre');
1885 1885
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 // mais apres la fonction autoriser()
115 115
 if ($f = find_in_path('mes_fonctions.php')) {
116 116
 	global $dossier_squelettes;
117
-	include_once(_ROOT_CWD . $f);
117
+	include_once(_ROOT_CWD.$f);
118 118
 }
119 119
 
120 120
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : [];
149 149
 		$qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
150 150
 	} elseif (is_numeric($qui)) {
151
-		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
151
+		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui);
152 152
 	}
153 153
 
154 154
 	// Admins restreints, on construit ici (pas generique mais...)
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 
160 160
 	spip_log(
161
-		"autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?',
162
-		'autoriser' . _LOG_DEBUG
161
+		"autoriser $faire $type $id (".(isset($qui['nom']) ? $qui['nom'] : '').') ?',
162
+		'autoriser'._LOG_DEBUG
163 163
 	);
164 164
 
165 165
 	// passer par objet_type pour avoir les alias
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		(isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier'))
172 172
 		or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier'))
173 173
 	) {
174
-		spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG);
174
+		spip_log("autoriser ($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : OK Exception', 'autoriser'._LOG_DEBUG);
175 175
 		return true;
176 176
 	}
177 177
 
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
 	// autoriser_faire[_dist], autoriser_defaut[_dist]
181 181
 	$fonctions = $type
182 182
 		? [
183
-			'autoriser_' . $type . '_' . $faire,
184
-			'autoriser_' . $type . '_' . $faire . '_dist',
185
-			'autoriser_' . $type,
186
-			'autoriser_' . $type . '_dist',
187
-			'autoriser_' . $faire,
188
-			'autoriser_' . $faire . '_dist',
183
+			'autoriser_'.$type.'_'.$faire,
184
+			'autoriser_'.$type.'_'.$faire.'_dist',
185
+			'autoriser_'.$type,
186
+			'autoriser_'.$type.'_dist',
187
+			'autoriser_'.$faire,
188
+			'autoriser_'.$faire.'_dist',
189 189
 			'autoriser_defaut',
190 190
 			'autoriser_defaut_dist'
191 191
 		]
192 192
 		: [
193
-			'autoriser_' . $faire,
194
-			'autoriser_' . $faire . '_dist',
193
+			'autoriser_'.$faire,
194
+			'autoriser_'.$faire.'_dist',
195 195
 			'autoriser_defaut',
196 196
 			'autoriser_defaut_dist'
197 197
 		];
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	spip_log(
207
-		"$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'),
208
-		'autoriser' . _LOG_DEBUG
207
+		"$f($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : '.($a ? 'OK' : 'niet'),
208
+		'autoriser'._LOG_DEBUG
209 209
 	);
210 210
 
211 211
 	return $a;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) {
334 334
 
335 335
 	// Le visiteur a-t-il un statut prevu par la config ?
336
-	if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) {
336
+	if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) {
337 337
 		return test_previsualiser_objet_champ($type, $id, $qui, $opt);
338 338
 	}
339 339
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 				} // pas de champ passe a la demande => NIET
391 391
 				$previsu = explode(',', $c['previsu']);
392 392
 				// regarder si ce statut est autorise pour l'auteur
393
-				if (in_array($opt[$champ] . '/auteur', $previsu)) {
393
+				if (in_array($opt[$champ].'/auteur', $previsu)) {
394 394
 					// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
395 395
 					// sinon l’auteur en session
396 396
 					include_spip('inc/securiser_action');
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 
405 405
 					if (!$id_auteur) {
406 406
 						return false;
407
-					} elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) {
407
+					} elseif (autoriser('previsualiser'.$opt[$champ], $type, '', $id_auteur)) {
408 408
 						// dans ce cas (admin en general), pas de filtrage sur ce statut
409 409
 					} elseif (
410 410
 						!sql_countsel(
411 411
 							'spip_auteurs_liens',
412
-							'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id)
412
+							'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id)
413 413
 						)
414 414
 					) {
415 415
 						return false;
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
 			// multilinguisme par secteur et objet rattaché à une rubrique
453 453
 			$primary = id_table_objet($type);
454 454
 			if ($table != 'spip_rubriques') {
455
-				$id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id));
455
+				$id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id));
456 456
 			} else {
457 457
 				$id_rubrique = $id;
458 458
 			}
459
-			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
459
+			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique));
460 460
 			if (!$id_secteur > 0) {
461 461
 				$id_secteur = $id_rubrique;
462 462
 			}
463
-			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur));
464
-			$langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id));
463
+			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur));
464
+			$langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id));
465 465
 			if ($langue_secteur != $langue_objet) {
466 466
 				// configuration incohérente, on laisse l'utilisateur corriger la situation
467 467
 				return true;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
470 470
 				return false;
471 471
 			} else {
472
-				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id));
472
+				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id));
473 473
 				if ($id_parent != 0) {
474 474
 					// sous-rubriques : pas de choix de langue
475 475
 					return false;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 
518 518
 	if (!isset($opt['statut'])) {
519 519
 		if (isset($desc['field']['statut'])) {
520
-			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id));
520
+			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id));
521 521
 		} else {
522 522
 			$statut = 'publie';
523 523
 		} // pas de statut => publie
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 		return false;
678 678
 	}
679 679
 
680
-	if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) {
680
+	if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) {
681 681
 		return false;
682 682
 	}
683 683
 
684
-	if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) {
684
+	if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) {
685 685
 		return false;
686 686
 	}
687 687
 
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
  * @return bool          true s'il a le droit, false sinon
714 714
  **/
715 715
 function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) {
716
-	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
716
+	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id));
717 717
 
718 718
 	return
719 719
 		$r
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 				(!isset($opt['statut']) or $opt['statut'] !== 'publie')
725 725
 				and in_array($qui['statut'], ['0minirezo', '1comite'])
726 726
 				and in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
727
-				and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
727
+				and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])
728 728
 			)
729 729
 		);
730 730
 }
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		if (!$id) {
779 779
 			return false;
780 780
 		}
781
-		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id));
781
+		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id));
782 782
 	}
783 783
 
784 784
 	return
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 		or
790 790
 		($id
791 791
 			and $qui['id_auteur']
792
-			and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']));
792
+			and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']));
793 793
 }
794 794
 
795 795
 
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 function autoriser_voir_dist($faire, $type, $id, $qui, $opt) {
809 809
 	# securite, mais on aurait pas du arriver ici !
810 810
 	if (
811
-		function_exists($f = 'autoriser_' . $type . '_voir')
812
-		or function_exists($f = 'autoriser_' . $type . '_voir_dist')
811
+		function_exists($f = 'autoriser_'.$type.'_voir')
812
+		or function_exists($f = 'autoriser_'.$type.'_voir_dist')
813 813
 	) {
814 814
 		return $f($faire, $type, $id, $qui, $opt);
815 815
 	}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	$n = sql_fetsel(
930 930
 		'A.id_article',
931 931
 		'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
932
-		"A.statut='publie' AND L.id_auteur=" . sql_quote($id)
932
+		"A.statut='publie' AND L.id_auteur=".sql_quote($id)
933 933
 	);
934 934
 
935 935
 	return $n ? true : false;
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 		and $r = sql_allfetsel(
1132 1132
 			'id_objet',
1133 1133
 			'spip_auteurs_liens',
1134
-			'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0"
1134
+			'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0"
1135 1135
 		)
1136 1136
 		and count($r)
1137 1137
 	) {
@@ -1747,8 +1747,8 @@  discard block
 block discarded – undo
1747 1747
 function auteurs_objet($objet, $id_objet, $cond = '') {
1748 1748
 	$objet = objet_type($objet);
1749 1749
 	$where = [
1750
-		'objet=' . sql_quote($objet),
1751
-		'id_objet=' . intval($id_objet)
1750
+		'objet='.sql_quote($objet),
1751
+		'id_objet='.intval($id_objet)
1752 1752
 	];
1753 1753
 	if (!empty($cond)) {
1754 1754
 		if (is_array($cond)) {
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 	return sql_allfetsel(
1784 1784
 		'id_auteur',
1785 1785
 		'spip_auteurs_liens',
1786
-		"objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '')
1786
+		"objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '')
1787 1787
 	);
1788 1788
 }
1789 1789
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -238,8 +238,7 @@  discard block
 block discarded – undo
238 238
 		if ($id === '*') {
239 239
 			unset($GLOBALS['autoriser_exception'][$faire][$type]);
240 240
 			unset($autorisation[$faire][$type]);
241
-		}
242
-		else {
241
+		} else {
243 242
 			unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
244 243
 			unset($autorisation[$faire][$type][$id]);
245 244
 		}
@@ -598,8 +597,7 @@  discard block
 block discarded – undo
598 597
 function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) {
599 598
 	if (!empty($opt['id_parent'])) {
600 599
 		return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
601
-	}
602
-	else {
600
+	} else {
603 601
 		return autoriser('defaut', null, null, $qui, $opt);
604 602
 	}
605 603
 }
@@ -745,8 +743,7 @@  discard block
 block discarded – undo
745 743
 	if (!empty($opt['id_parent'])) {
746 744
 		// creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
747 745
 		return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
748
-	}
749
-	else {
746
+	} else {
750 747
 		return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite']));
751 748
 	}
752 749
 }
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 2 patches
Indentation   +73 added lines, -73 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
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function autosave_clean_value($val) {
30
-	return stripslashes(urldecode($val));
30
+    return stripslashes(urldecode($val));
31 31
 }
32 32
 
33 33
 /**
@@ -38,58 +38,58 @@  discard block
 block discarded – undo
38 38
  * @return array
39 39
  */
40 40
 function cvtautosave_formulaire_charger($flux) {
41
-	if (
42
-		is_array($flux['data'])
43
-		and isset($flux['data']['_autosave_id'])
44
-		and $cle_autosave = $flux['data']['_autosave_id']
45
-	) {
46
-		$form = $flux['args']['form'];
47
-		$je_suis_poste = $flux['args']['je_suis_poste'];
41
+    if (
42
+        is_array($flux['data'])
43
+        and isset($flux['data']['_autosave_id'])
44
+        and $cle_autosave = $flux['data']['_autosave_id']
45
+    ) {
46
+        $form = $flux['args']['form'];
47
+        $je_suis_poste = $flux['args']['je_suis_poste'];
48 48
 
49
-		$cle_autosave = serialize($cle_autosave);
50
-		$cle_autosave = $form . '_' . md5($cle_autosave);
49
+        $cle_autosave = serialize($cle_autosave);
50
+        $cle_autosave = $form . '_' . md5($cle_autosave);
51 51
 
52
-		// si on a un backup en session et qu'on est au premier chargement, non poste
53
-		// on restitue les donnees
54
-		if (
55
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
56
-			and !$je_suis_poste
57
-		) {
58
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
59
-			foreach ($vars as $key => $val) {
60
-				if (isset($flux['data'][$key])) {
61
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
62
-						'autosave_clean_value',
63
-						$val
64
-					));
65
-				}
66
-			}
67
-		}
52
+        // si on a un backup en session et qu'on est au premier chargement, non poste
53
+        // on restitue les donnees
54
+        if (
55
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
56
+            and !$je_suis_poste
57
+        ) {
58
+            parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
59
+            foreach ($vars as $key => $val) {
60
+                if (isset($flux['data'][$key])) {
61
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
62
+                        'autosave_clean_value',
63
+                        $val
64
+                    ));
65
+                }
66
+            }
67
+        }
68 68
 
69
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
70
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
71
-		if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72
-			terminer_actualiser_sessions();
73
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
-				session_set('session_autosave_' . $cle_autosave, null);
76
-				// en court sleep pour etre certain que la concurrence est finie
77
-				sleep(1);
78
-				terminer_actualiser_sessions();
79
-			}
80
-		}
69
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
70
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
71
+        if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72
+            terminer_actualiser_sessions();
73
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
+                session_set('session_autosave_' . $cle_autosave, null);
76
+                // en court sleep pour etre certain que la concurrence est finie
77
+                sleep(1);
78
+                terminer_actualiser_sessions();
79
+            }
80
+        }
81 81
 
82 82
 
83
-		/**
84
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
85
-		 */
86
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
83
+        /**
84
+         * Envoyer le input hidden et le bout de js qui l'utilisera
85
+         */
86
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
88 88
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
89 89
 			});/*]]>*/</script>';
90
-	}
90
+    }
91 91
 
92
-	return $flux;
92
+    return $flux;
93 93
 }
94 94
 
95 95
 /**
@@ -103,33 +103,33 @@  discard block
 block discarded – undo
103 103
  * @return array
104 104
  */
105 105
 function cvtautosave_formulaire_traiter($flux) {
106
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
107
-	// on elimine les donnees de la session
108
-	if ($cle_autosave = _request('autosave')) {
109
-		include_spip('inc/session');
110
-		session_set('session_autosave_' . $cle_autosave, null);
111
-	}
106
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
107
+    // on elimine les donnees de la session
108
+    if ($cle_autosave = _request('autosave')) {
109
+        include_spip('inc/session');
110
+        session_set('session_autosave_' . $cle_autosave, null);
111
+    }
112 112
 
113
-	if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
114
-		// delai par defaut avant purge d'un backup de form : 72H
115
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
116
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
117
-		}
118
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
119
-		// purger aussi toutes les vieilles autosave
120
-		$session = $GLOBALS['visiteur_session'];
121
-		foreach ($session as $k => $v) {
122
-			if (strncmp($k, 'session_autosave_', 17) == 0) {
123
-				$timestamp = 0;
124
-				if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
125
-					$timestamp = intval($m[1]);
126
-				}
127
-				if ($timestamp < $time_too_old) {
128
-					session_set($k, null);
129
-				}
130
-			}
131
-		}
132
-	}
113
+    if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
114
+        // delai par defaut avant purge d'un backup de form : 72H
115
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
116
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
117
+        }
118
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
119
+        // purger aussi toutes les vieilles autosave
120
+        $session = $GLOBALS['visiteur_session'];
121
+        foreach ($session as $k => $v) {
122
+            if (strncmp($k, 'session_autosave_', 17) == 0) {
123
+                $timestamp = 0;
124
+                if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
125
+                    $timestamp = intval($m[1]);
126
+                }
127
+                if ($timestamp < $time_too_old) {
128
+                    session_set($k, null);
129
+                }
130
+            }
131
+        }
132
+    }
133 133
 
134
-	return $flux;
134
+    return $flux;
135 135
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 		$je_suis_poste = $flux['args']['je_suis_poste'];
48 48
 
49 49
 		$cle_autosave = serialize($cle_autosave);
50
-		$cle_autosave = $form . '_' . md5($cle_autosave);
50
+		$cle_autosave = $form.'_'.md5($cle_autosave);
51 51
 
52 52
 		// si on a un backup en session et qu'on est au premier chargement, non poste
53 53
 		// on restitue les donnees
54 54
 		if (
55
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+			isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
56 56
 			and !$je_suis_poste
57 57
 		) {
58
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+			parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
59 59
 			foreach ($vars as $key => $val) {
60 60
 				if (isset($flux['data'][$key])) {
61 61
 					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 		if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72 72
 			terminer_actualiser_sessions();
73 73
 			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
-				session_set('session_autosave_' . $cle_autosave, null);
74
+			if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) {
75
+				session_set('session_autosave_'.$cle_autosave, null);
76 76
 				// en court sleep pour etre certain que la concurrence est finie
77 77
 				sleep(1);
78 78
 				terminer_actualiser_sessions();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		 */
86 86
 		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87 87
 			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
88
-		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88
+		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
89 89
 			});/*]]>*/</script>';
90 90
 	}
91 91
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	// on elimine les donnees de la session
108 108
 	if ($cle_autosave = _request('autosave')) {
109 109
 		include_spip('inc/session');
110
-		session_set('session_autosave_' . $cle_autosave, null);
110
+		session_set('session_autosave_'.$cle_autosave, null);
111 111
 	}
112 112
 
113 113
 	if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
Please login to merge, or discard this patch.
ecrire/inc/roles.php 2 patches
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 if (!defined('_ECRIRE_INC_VERSION')) {
31
-	return;
31
+    return;
32 32
 }
33 33
 
34 34
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
  *     array : description des roles applicables dans 3 index : colonne, titres, roles
49 49
  **/
50 50
 function roles_presents($objet, $objet_destination = '') {
51
-	$desc = lister_tables_objets_sql(table_objet_sql($objet));
52
-
53
-	// pas de liste de roles, on sort
54
-	if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
-		return false;
56
-	}
57
-
58
-	// on vérifie que la table de liaison existe
59
-	include_spip('action/editer_liens');
60
-	if (!$lien = objet_associable($objet)) {
61
-		return false;
62
-	}
63
-
64
-	// on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
-	$colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
-	$trouver_table = charger_fonction('trouver_table', 'base');
67
-	list(, $table_lien) = $lien;
68
-	$desc_lien = $trouver_table($table_lien);
69
-	if (!isset($desc_lien['field'][$colonne])) {
70
-		return false;
71
-	}
72
-
73
-	// sur quoi peuvent s'appliquer nos rôles
74
-	if (!$application = $desc['roles_objets']) {
75
-		return false;
76
-	}
77
-
78
-	// destination presente, on restreint si possible
79
-	if ($objet_destination) {
80
-		$objet_destination = table_objet($objet_destination);
81
-
82
-		// pour l'objet
83
-		if (isset($application[$objet_destination])) {
84
-			$application = $application[$objet_destination];
85
-			// sinon pour tous les objets
86
-		} elseif (isset($application['*'])) {
87
-			$application = $application['*'];
88
-		} // sinon tant pis
89
-		else {
90
-			return false;
91
-		}
92
-	}
93
-
94
-	// tout est ok
95
-	return [
96
-		'titres' => $titres,
97
-		'roles' => $application,
98
-		'colonne' => $colonne
99
-	];
51
+    $desc = lister_tables_objets_sql(table_objet_sql($objet));
52
+
53
+    // pas de liste de roles, on sort
54
+    if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
+        return false;
56
+    }
57
+
58
+    // on vérifie que la table de liaison existe
59
+    include_spip('action/editer_liens');
60
+    if (!$lien = objet_associable($objet)) {
61
+        return false;
62
+    }
63
+
64
+    // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
+    $colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
+    $trouver_table = charger_fonction('trouver_table', 'base');
67
+    list(, $table_lien) = $lien;
68
+    $desc_lien = $trouver_table($table_lien);
69
+    if (!isset($desc_lien['field'][$colonne])) {
70
+        return false;
71
+    }
72
+
73
+    // sur quoi peuvent s'appliquer nos rôles
74
+    if (!$application = $desc['roles_objets']) {
75
+        return false;
76
+    }
77
+
78
+    // destination presente, on restreint si possible
79
+    if ($objet_destination) {
80
+        $objet_destination = table_objet($objet_destination);
81
+
82
+        // pour l'objet
83
+        if (isset($application[$objet_destination])) {
84
+            $application = $application[$objet_destination];
85
+            // sinon pour tous les objets
86
+        } elseif (isset($application['*'])) {
87
+            $application = $application['*'];
88
+        } // sinon tant pis
89
+        else {
90
+            return false;
91
+        }
92
+    }
93
+
94
+    // tout est ok
95
+    return [
96
+        'titres' => $titres,
97
+        'roles' => $application,
98
+        'colonne' => $colonne
99
+    ];
100 100
 }
101 101
 
102 102
 /**
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
  *     Nom de la colonne, sinon vide
111 111
  **/
112 112
 function roles_colonne($objet, $objet_destination) {
113
-	if ($roles = roles_presents($objet, $objet_destination)) {
114
-		return $roles['colonne'];
115
-	}
113
+    if ($roles = roles_presents($objet, $objet_destination)) {
114
+        return $roles['colonne'];
115
+    }
116 116
 
117
-	return '';
117
+    return '';
118 118
 }
119 119
 
120 120
 
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
  *     Liste ('', '', array()) sinon.
137 137
  **/
138 138
 function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) {
139
-	// si des rôles sont possibles, on les utilise
140
-	$role = $colonne_role = ''; # role défini
141
-	// condition du where par defaut
142
-	$cond = [];
143
-	if ($roles = roles_presents($objet, $objet_destination)) {
144
-		$colonne_role = $roles['colonne'];
145
-		// qu'il n'est pas défini
146
-		if (
147
-			!isset($qualif[$colonne_role])
148
-			or !($role = $qualif[$colonne_role])
149
-		) {
150
-			$role = $roles['roles']['defaut'];
151
-		}
152
-		// where
153
-		$cond = ["$colonne_role=" . sql_quote($role)];
154
-	}
155
-
156
-	return [$role, $colonne_role, $cond];
139
+    // si des rôles sont possibles, on les utilise
140
+    $role = $colonne_role = ''; # role défini
141
+    // condition du where par defaut
142
+    $cond = [];
143
+    if ($roles = roles_presents($objet, $objet_destination)) {
144
+        $colonne_role = $roles['colonne'];
145
+        // qu'il n'est pas défini
146
+        if (
147
+            !isset($qualif[$colonne_role])
148
+            or !($role = $qualif[$colonne_role])
149
+        ) {
150
+            $role = $roles['roles']['defaut'];
151
+        }
152
+        // where
153
+        $cond = ["$colonne_role=" . sql_quote($role)];
154
+    }
155
+
156
+    return [$role, $colonne_role, $cond];
157 157
 }
158 158
 
159 159
 /**
@@ -175,21 +175,21 @@  discard block
 block discarded – undo
175 175
  *     Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé)
176 176
  **/
177 177
 function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) {
178
-	// role par défaut, colonne
179
-	list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
178
+    // role par défaut, colonne
179
+    list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
180 180
 
181
-	// chercher d'eventuels rôles transmis
182
-	$role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
183
-	unset($cond['role']); // cette condition est particuliere...
181
+    // chercher d'eventuels rôles transmis
182
+    $role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
183
+    unset($cond['role']); // cette condition est particuliere...
184 184
 
185
-	if ($colonne_role) {
186
-		// on ajoute la condition du role aux autres conditions.
187
-		if ($role != '*') {
188
-			$cond[] = "$colonne_role=" . sql_quote($role);
189
-		}
190
-	}
185
+    if ($colonne_role) {
186
+        // on ajoute la condition du role aux autres conditions.
187
+        if ($role != '*') {
188
+            $cond[] = "$colonne_role=" . sql_quote($role);
189
+        }
190
+    }
191 191
 
192
-	return [$cond, $colonne_role, $role];
192
+    return [$cond, $colonne_role, $role];
193 193
 }
194 194
 
195 195
 /**
@@ -211,28 +211,28 @@  discard block
 block discarded – undo
211 211
  */
212 212
 function roles_complets($objet_source, $objet, $id_objet, $objet_lien) {
213 213
 
214
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
215
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
216
-	if ($presents === false) {
217
-		return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
218
-	}
219
-
220
-	// types de roles possibles
221
-	$roles_possibles = $presents['roles']['roles']['choix'];
222
-	// couples id / roles
223
-	$ids = $presents['ids'];
224
-
225
-	// pour chaque groupe, on fait le diff entre tous les roles possibles
226
-	// et les roles attribués à l'élément : s'il en reste, c'est que l'élément
227
-	// n'est pas complet
228
-	$complets = [];
229
-	foreach ($ids as $id => $roles_presents) {
230
-		if (!array_diff($roles_possibles, $roles_presents)) {
231
-			$complets[] = $id;
232
-		}
233
-	}
234
-
235
-	return $complets;
214
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
215
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
216
+    if ($presents === false) {
217
+        return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
218
+    }
219
+
220
+    // types de roles possibles
221
+    $roles_possibles = $presents['roles']['roles']['choix'];
222
+    // couples id / roles
223
+    $ids = $presents['ids'];
224
+
225
+    // pour chaque groupe, on fait le diff entre tous les roles possibles
226
+    // et les roles attribués à l'élément : s'il en reste, c'est que l'élément
227
+    // n'est pas complet
228
+    $complets = [];
229
+    foreach ($ids as $id => $roles_presents) {
230
+        if (!array_diff($roles_possibles, $roles_presents)) {
231
+            $complets[] = $id;
232
+        }
233
+    }
234
+
235
+    return $complets;
236 236
 }
237 237
 
238 238
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) {
251 251
 
252
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
253
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
254
-	if ($presents === false) {
255
-		return [];
256
-	}
252
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
253
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
254
+    if ($presents === false) {
255
+        return [];
256
+    }
257 257
 
258
-	if (!isset($presents['ids'][$id_objet_source])) {
259
-		return [];
260
-	}
258
+    if (!isset($presents['ids'][$id_objet_source])) {
259
+        return [];
260
+    }
261 261
 
262
-	return $presents['ids'][$id_objet_source];
262
+    return $presents['ids'][$id_objet_source];
263 263
 }
264 264
 
265 265
 
@@ -287,47 +287,47 @@  discard block
 block discarded – undo
287 287
  *     - False si pas de role déclarés
288 288
  */
289 289
 function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) {
290
-	static $done = [];
291
-
292
-	// stocker le résultat
293
-	$hash = "$objet_source-$objet-$id_objet-$objet_lien";
294
-	if (isset($done[$hash])) {
295
-		return $done[$hash];
296
-	}
297
-
298
-	// pas de roles sur ces objets, on sort
299
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
300
-	if (!$roles) {
301
-		return $done[$hash] = false;
302
-	}
303
-
304
-	// inspiré de lister_objets_lies()
305
-	if ($objet_lien == $objet) {
306
-		$res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
307
-	} else {
308
-		$res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
309
-	}
310
-
311
-	// types de roles possibles
312
-	$roles_possibles = $roles['roles']['choix'];
313
-	// colonne du role
314
-	$colonne = $roles['colonne'];
315
-
316
-	// on recupere par id, et role existant
317
-	$ids = [];
318
-	while ($row = array_shift($res)) {
319
-		$id = $row[$objet_source];
320
-		if (!isset($ids[$id])) {
321
-			$ids[$id] = [];
322
-		}
323
-		// tableau des roles présents
324
-		$ids[$id][] = $row[$colonne];
325
-	}
326
-
327
-	return $done[$hash] = [
328
-		'roles' => $roles,
329
-		'ids' => $ids
330
-	];
290
+    static $done = [];
291
+
292
+    // stocker le résultat
293
+    $hash = "$objet_source-$objet-$id_objet-$objet_lien";
294
+    if (isset($done[$hash])) {
295
+        return $done[$hash];
296
+    }
297
+
298
+    // pas de roles sur ces objets, on sort
299
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
300
+    if (!$roles) {
301
+        return $done[$hash] = false;
302
+    }
303
+
304
+    // inspiré de lister_objets_lies()
305
+    if ($objet_lien == $objet) {
306
+        $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
307
+    } else {
308
+        $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
309
+    }
310
+
311
+    // types de roles possibles
312
+    $roles_possibles = $roles['roles']['choix'];
313
+    // colonne du role
314
+    $colonne = $roles['colonne'];
315
+
316
+    // on recupere par id, et role existant
317
+    $ids = [];
318
+    while ($row = array_shift($res)) {
319
+        $id = $row[$objet_source];
320
+        if (!isset($ids[$id])) {
321
+            $ids[$id] = [];
322
+        }
323
+        // tableau des roles présents
324
+        $ids[$id][] = $row[$colonne];
325
+    }
326
+
327
+    return $done[$hash] = [
328
+        'roles' => $roles,
329
+        'ids' => $ids
330
+    ];
331 331
 }
332 332
 
333 333
 
@@ -345,33 +345,33 @@  discard block
 block discarded – undo
345 345
  *     - false si pas de role déclarés
346 346
  */
347 347
 function roles_connus_en_base($objet_source, $objet, $objet_lien) {
348
-	static $done = [];
349
-
350
-	// stocker le résultat
351
-	$hash = "$objet_source-$objet-$objet_lien";
352
-	if (isset($done[$hash])) {
353
-		return $done[$hash];
354
-	}
355
-
356
-	if (!$lien = objet_associable($objet_lien)) {
357
-		return $done[$hash] = false;
358
-	}
359
-
360
-	// pas de roles sur ces objets, on sort
361
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
362
-	if (!$roles) {
363
-		return $done[$hash] = false;
364
-	}
365
-
366
-	list($primary, $l) = $lien;
367
-	$colone_role = $roles['colonne'];
368
-
369
-	$all = sql_allfetsel(
370
-		"DISTINCT $colone_role",
371
-		$l,
372
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373
-	);
374
-	$done[$hash] = array_map('reset', $all);
375
-
376
-	return $done[$hash];
348
+    static $done = [];
349
+
350
+    // stocker le résultat
351
+    $hash = "$objet_source-$objet-$objet_lien";
352
+    if (isset($done[$hash])) {
353
+        return $done[$hash];
354
+    }
355
+
356
+    if (!$lien = objet_associable($objet_lien)) {
357
+        return $done[$hash] = false;
358
+    }
359
+
360
+    // pas de roles sur ces objets, on sort
361
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
362
+    if (!$roles) {
363
+        return $done[$hash] = false;
364
+    }
365
+
366
+    list($primary, $l) = $lien;
367
+    $colone_role = $roles['colonne'];
368
+
369
+    $all = sql_allfetsel(
370
+        "DISTINCT $colone_role",
371
+        $l,
372
+        'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373
+    );
374
+    $done[$hash] = array_map('reset', $all);
375
+
376
+    return $done[$hash];
377 377
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			$role = $roles['roles']['defaut'];
151 151
 		}
152 152
 		// where
153
-		$cond = ["$colonne_role=" . sql_quote($role)];
153
+		$cond = ["$colonne_role=".sql_quote($role)];
154 154
 	}
155 155
 
156 156
 	return [$role, $colonne_role, $cond];
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	if ($colonne_role) {
186 186
 		// on ajoute la condition du role aux autres conditions.
187 187
 		if ($role != '*') {
188
-			$cond[] = "$colonne_role=" . sql_quote($role);
188
+			$cond[] = "$colonne_role=".sql_quote($role);
189 189
 		}
190 190
 	}
191 191
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	$all = sql_allfetsel(
370 370
 		"DISTINCT $colone_role",
371 371
 		$l,
372
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
+		'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373 373
 	);
374 374
 	$done[$hash] = array_map('reset', $all);
375 375
 
Please login to merge, or discard this patch.
ecrire/inc/commencer_page.php 2 patches
Indentation   +64 added lines, -64 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,25 +43,25 @@  discard block
 block discarded – undo
43 43
  * @return string Code HTML
44 44
  **/
45 45
 function inc_commencer_page_dist(
46
-	$titre = '',
47
-	$rubrique = 'accueil',
48
-	$sous_rubrique = 'accueil',
49
-	$id_rubrique = '',
50
-	$menu = true,
51
-	$minipres = false,
52
-	$alertes = true
46
+    $titre = '',
47
+    $rubrique = 'accueil',
48
+    $sous_rubrique = 'accueil',
49
+    $id_rubrique = '',
50
+    $menu = true,
51
+    $minipres = false,
52
+    $alertes = true
53 53
 ) {
54 54
 
55
-	include_spip('inc/headers');
55
+    include_spip('inc/headers');
56 56
 
57
-	http_no_cache();
57
+    http_no_cache();
58 58
 
59
-	return init_entete($titre, $id_rubrique, $minipres)
60
-	. init_body($rubrique, $sous_rubrique, $id_rubrique, $menu)
61
-	. "<div id='page'>"
62
-	. auteurs_recemment_connectes($GLOBALS['connect_id_auteur'])
63
-	. ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '')
64
-	. '<div class="largeur">';
59
+    return init_entete($titre, $id_rubrique, $minipres)
60
+    . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu)
61
+    . "<div id='page'>"
62
+    . auteurs_recemment_connectes($GLOBALS['connect_id_auteur'])
63
+    . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '')
64
+    . '<div class="largeur">';
65 65
 }
66 66
 
67 67
 /**
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
  *     Entête du fichier HTML avec le DOCTYPE
83 83
  */
84 84
 function init_entete($titre = '', $dummy = 0, $minipres = false) {
85
-	include_spip('inc/texte');
86
-	if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
87
-		$nom_site_spip = _T('info_mon_site_spip');
88
-	}
89
-
90
-	$titre = '['
91
-		. $nom_site_spip
92
-		. ']'
93
-		. ($titre ? ' ' . textebrut(typo($titre)) : '');
94
-
95
-	return _DOCTYPE_ECRIRE
96
-	. html_lang_attributes()
97
-	. "<head>\n"
98
-	. init_head($titre, $dummy, $minipres)
99
-	. "</head>\n";
85
+    include_spip('inc/texte');
86
+    if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
87
+        $nom_site_spip = _T('info_mon_site_spip');
88
+    }
89
+
90
+    $titre = '['
91
+        . $nom_site_spip
92
+        . ']'
93
+        . ($titre ? ' ' . textebrut(typo($titre)) : '');
94
+
95
+    return _DOCTYPE_ECRIRE
96
+    . html_lang_attributes()
97
+    . "<head>\n"
98
+    . init_head($titre, $dummy, $minipres)
99
+    . "</head>\n";
100 100
 }
101 101
 
102 102
 /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
  * @return string
111 111
  */
112 112
 function init_head($titre = '', $dummy = 0, $minipres = false) {
113
-	return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']);
113
+    return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']);
114 114
 }
115 115
 
116 116
 /**
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) {
134 134
 
135
-	$res = pipeline('body_prive', "<body class='"
136
-		. init_body_class() . ' ' . _request('exec') . "'"
137
-		. ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '')
138
-		. '>');
135
+    $res = pipeline('body_prive', "<body class='"
136
+        . init_body_class() . ' ' . _request('exec') . "'"
137
+        . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '')
138
+        . '>');
139 139
 
140
-	if (!$menu) {
141
-		return $res;
142
-	}
140
+    if (!$menu) {
141
+        return $res;
142
+    }
143 143
 
144 144
 
145
-	$bandeau = charger_fonction('bandeau', 'inc');
145
+    $bandeau = charger_fonction('bandeau', 'inc');
146 146
 
147
-	return $res
148
-	. $bandeau();
147
+    return $res
148
+    . $bandeau();
149 149
 }
150 150
 
151 151
 /**
@@ -157,27 +157,27 @@  discard block
 block discarded – undo
157 157
  * @return string Classes CSS (séparées par des espaces)
158 158
  */
159 159
 function init_body_class() {
160
-	$prefs = isset($GLOBALS['visiteur_session']['prefs']) ? $GLOBALS['visiteur_session']['prefs'] : [];
161
-
162
-	$GLOBALS['spip_display'] = isset($prefs['display']) ? (int) $prefs['display'] : 2;
163
-	$spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones';
164
-	$spip_display_outils = isset($prefs['display_outils'])
165
-		? ($prefs['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils')
166
-		: 'navigation_avec_outils';
167
-	$GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? spip_sanitize_classname($_COOKIE['spip_ecran']) : 'etroit';
168
-
169
-	$display_class = [
170
-		0 => 'icones_img_texte'
171
-		/*init*/,
172
-		1 => 'icones_texte',
173
-		2 => 'icones_img_texte',
174
-		3 => 'icones_img'
175
-	];
176
-
177
-	$couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 2;
178
-
179
-	$classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
180
-	return spip_sanitize_classname($classes);
160
+    $prefs = isset($GLOBALS['visiteur_session']['prefs']) ? $GLOBALS['visiteur_session']['prefs'] : [];
161
+
162
+    $GLOBALS['spip_display'] = isset($prefs['display']) ? (int) $prefs['display'] : 2;
163
+    $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones';
164
+    $spip_display_outils = isset($prefs['display_outils'])
165
+        ? ($prefs['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils')
166
+        : 'navigation_avec_outils';
167
+    $GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? spip_sanitize_classname($_COOKIE['spip_ecran']) : 'etroit';
168
+
169
+    $display_class = [
170
+        0 => 'icones_img_texte'
171
+        /*init*/,
172
+        1 => 'icones_texte',
173
+        2 => 'icones_img_texte',
174
+        3 => 'icones_img'
175
+    ];
176
+
177
+    $couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 2;
178
+
179
+    $classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
180
+    return spip_sanitize_classname($classes);
181 181
 }
182 182
 
183 183
 
@@ -188,5 +188,5 @@  discard block
 block discarded – undo
188 188
  * @return string
189 189
  */
190 190
 function auteurs_recemment_connectes($id_auteur) {
191
-	return recuperer_fond('prive/objets/liste/auteurs_enligne');
191
+    return recuperer_fond('prive/objets/liste/auteurs_enligne');
192 192
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	$titre = '['
91 91
 		. $nom_site_spip
92 92
 		. ']'
93
-		. ($titre ? ' ' . textebrut(typo($titre)) : '');
93
+		. ($titre ? ' '.textebrut(typo($titre)) : '');
94 94
 
95 95
 	return _DOCTYPE_ECRIRE
96 96
 	. html_lang_attributes()
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) {
134 134
 
135 135
 	$res = pipeline('body_prive', "<body class='"
136
-		. init_body_class() . ' ' . _request('exec') . "'"
136
+		. init_body_class().' '._request('exec')."'"
137 137
 		. ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '')
138 138
 		. '>');
139 139
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 	$couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 2;
178 178
 
179
-	$classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
179
+	$classes = $GLOBALS['spip_ecran']." spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils ".$display_class[$GLOBALS['spip_display']];
180 180
 	return spip_sanitize_classname($classes);
181 181
 }
182 182
 
Please login to merge, or discard this patch.
ecrire/inc/csv.php 2 patches
Indentation   +108 added lines, -108 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
 /**
@@ -33,118 +33,118 @@  discard block
 block discarded – undo
33 33
  **/
34 34
 function analyse_csv($t) {
35 35
 
36
-	// Quel est le séparateur ?
37
-	$virg = substr_count($t, ',');
38
-	$pvirg = substr_count($t, ';');
39
-	$tab = substr_count($t, "\t");
40
-	if ($virg > $pvirg) {
41
-		$sep = ',';
42
-		$hs = '&#44;';
43
-	} else {
44
-		$sep = ';';
45
-		$hs = '&#59;';
46
-		$virg = $pvirg;
47
-	}
48
-	// un certain nombre de tab => le séparateur est tab
49
-	if ($tab > $virg / 10) {
50
-		$sep = "\t";
51
-		$hs = "\t";
52
-	}
36
+    // Quel est le séparateur ?
37
+    $virg = substr_count($t, ',');
38
+    $pvirg = substr_count($t, ';');
39
+    $tab = substr_count($t, "\t");
40
+    if ($virg > $pvirg) {
41
+        $sep = ',';
42
+        $hs = '&#44;';
43
+    } else {
44
+        $sep = ';';
45
+        $hs = '&#59;';
46
+        $virg = $pvirg;
47
+    }
48
+    // un certain nombre de tab => le séparateur est tab
49
+    if ($tab > $virg / 10) {
50
+        $sep = "\t";
51
+        $hs = "\t";
52
+    }
53 53
 
54
-	// un separateur suivi de 3 guillemets attention !
55
-	// attention au ; ou , suceptible d'etre confondu avec un separateur
56
-	// on substitue un # et on remplacera a la fin
57
-	$t = preg_replace("/([\n$sep])\"\"\"/", '\\1"&#34#', $t);
58
-	$t = str_replace('""', '&#34#', $t);
59
-	preg_match_all('/"[^"]*"/', $t, $r);
60
-	foreach ($r[0] as $cell) {
61
-		$t = str_replace(
62
-			$cell,
63
-			str_replace(
64
-				$sep,
65
-				$hs,
66
-				str_replace(
67
-					"\n",
68
-					'``**``', // échapper les saut de lignes, on les remettra après.
69
-					substr($cell, 1, -1)
70
-				)
71
-			),
72
-			$t
73
-		);
74
-	}
54
+    // un separateur suivi de 3 guillemets attention !
55
+    // attention au ; ou , suceptible d'etre confondu avec un separateur
56
+    // on substitue un # et on remplacera a la fin
57
+    $t = preg_replace("/([\n$sep])\"\"\"/", '\\1"&#34#', $t);
58
+    $t = str_replace('""', '&#34#', $t);
59
+    preg_match_all('/"[^"]*"/', $t, $r);
60
+    foreach ($r[0] as $cell) {
61
+        $t = str_replace(
62
+            $cell,
63
+            str_replace(
64
+                $sep,
65
+                $hs,
66
+                str_replace(
67
+                    "\n",
68
+                    '``**``', // échapper les saut de lignes, on les remettra après.
69
+                    substr($cell, 1, -1)
70
+                )
71
+            ),
72
+            $t
73
+        );
74
+    }
75 75
 
76
-	$t = preg_replace(
77
-		'/\r?\n/',
78
-		"\n",
79
-		preg_replace('/[\r\n]+/', "\n", $t)
80
-	);
76
+    $t = preg_replace(
77
+        '/\r?\n/',
78
+        "\n",
79
+        preg_replace('/[\r\n]+/', "\n", $t)
80
+    );
81 81
 
82
-	list($entete, $corps) = explode("\n", $t, 2);
83
-	$caption = '';
84
-	// sauter la ligne de tete formee seulement de separateurs
85
-	if (substr_count($entete, $sep) == strlen($entete)) {
86
-		list($entete, $corps) = explode("\n", $corps, 2);
87
-	}
88
-	// si une seule colonne, en faire le titre
89
-	if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) {
90
-		$caption = "\n||" . $l[1] . '|';
91
-		list($entete, $corps) = explode("\n", $corps, 2);
92
-	}
93
-	// si premiere colonne vide, le raccourci doit quand meme produire <th...
94
-	if ($entete[0] == $sep) {
95
-		$entete = ' ' . $entete;
96
-	}
82
+    list($entete, $corps) = explode("\n", $t, 2);
83
+    $caption = '';
84
+    // sauter la ligne de tete formee seulement de separateurs
85
+    if (substr_count($entete, $sep) == strlen($entete)) {
86
+        list($entete, $corps) = explode("\n", $corps, 2);
87
+    }
88
+    // si une seule colonne, en faire le titre
89
+    if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) {
90
+        $caption = "\n||" . $l[1] . '|';
91
+        list($entete, $corps) = explode("\n", $corps, 2);
92
+    }
93
+    // si premiere colonne vide, le raccourci doit quand meme produire <th...
94
+    if ($entete[0] == $sep) {
95
+        $entete = ' ' . $entete;
96
+    }
97 97
 
98
-	$lignes = explode("\n", $corps);
98
+    $lignes = explode("\n", $corps);
99 99
 
100
-	// retrait des lignes vides finales
101
-	while (
102
-		count($lignes) > 0
103
-		and preg_match("/^$sep*$/", $lignes[count($lignes) - 1])
104
-	) {
105
-		unset($lignes[count($lignes) - 1]);
106
-	}
107
-	//  calcul du  nombre de colonne a chaque ligne
108
-	$nbcols = [];
109
-	$max = $mil = substr_count($entete, $sep);
110
-	foreach ($lignes as $k => $v) {
111
-		if ($max <> ($nbcols[$k] = substr_count($v, $sep))) {
112
-			if ($max > $nbcols[$k]) {
113
-				$mil = $nbcols[$k];
114
-			} else {
115
-				$mil = $max;
116
-				$max = $nbcols[$k];
117
-			}
118
-		}
119
-	}
120
-	// Si pas le meme nombre, cadrer au nombre max
121
-	if ($mil <> $max) {
122
-		foreach ($nbcols as $k => $v) {
123
-			if ($v < $max) {
124
-				$lignes[$k] .= str_repeat($sep, $max - $v);
125
-			}
126
-		}
127
-	}
128
-	// et retirer les colonnes integralement vides
129
-	while (true) {
130
-		$nbcols = ($entete[strlen($entete) - 1] === $sep);
131
-		foreach ($lignes as $v) {
132
-			$nbcols &= ($v[strlen($v) - 1] === $sep);
133
-		}
134
-		if (!$nbcols) {
135
-			break;
136
-		}
137
-		$entete = substr($entete, 0, -1);
138
-		foreach ($lignes as $k => $v) {
139
-			$lignes[$k] = substr($v, 0, -1);
140
-		}
141
-	}
100
+    // retrait des lignes vides finales
101
+    while (
102
+        count($lignes) > 0
103
+        and preg_match("/^$sep*$/", $lignes[count($lignes) - 1])
104
+    ) {
105
+        unset($lignes[count($lignes) - 1]);
106
+    }
107
+    //  calcul du  nombre de colonne a chaque ligne
108
+    $nbcols = [];
109
+    $max = $mil = substr_count($entete, $sep);
110
+    foreach ($lignes as $k => $v) {
111
+        if ($max <> ($nbcols[$k] = substr_count($v, $sep))) {
112
+            if ($max > $nbcols[$k]) {
113
+                $mil = $nbcols[$k];
114
+            } else {
115
+                $mil = $max;
116
+                $max = $nbcols[$k];
117
+            }
118
+        }
119
+    }
120
+    // Si pas le meme nombre, cadrer au nombre max
121
+    if ($mil <> $max) {
122
+        foreach ($nbcols as $k => $v) {
123
+            if ($v < $max) {
124
+                $lignes[$k] .= str_repeat($sep, $max - $v);
125
+            }
126
+        }
127
+    }
128
+    // et retirer les colonnes integralement vides
129
+    while (true) {
130
+        $nbcols = ($entete[strlen($entete) - 1] === $sep);
131
+        foreach ($lignes as $v) {
132
+            $nbcols &= ($v[strlen($v) - 1] === $sep);
133
+        }
134
+        if (!$nbcols) {
135
+            break;
136
+        }
137
+        $entete = substr($entete, 0, -1);
138
+        foreach ($lignes as $k => $v) {
139
+            $lignes[$k] = substr($v, 0, -1);
140
+        }
141
+    }
142 142
 
143
-	foreach ($lignes as &$l) {
144
-		$l = str_replace('&#34#', '"', $l);
145
-		$l = str_replace('``**``', "\n", $l);
146
-		$l = explode($sep, $l);
147
-	}
143
+    foreach ($lignes as &$l) {
144
+        $l = str_replace('&#34#', '"', $l);
145
+        $l = str_replace('``**``', "\n", $l);
146
+        $l = explode($sep, $l);
147
+    }
148 148
 
149
-	return [explode($sep, $entete), $lignes, $caption];
149
+    return [explode($sep, $entete), $lignes, $caption];
150 150
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,12 +87,12 @@
 block discarded – undo
87 87
 	}
88 88
 	// si une seule colonne, en faire le titre
89 89
 	if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) {
90
-		$caption = "\n||" . $l[1] . '|';
90
+		$caption = "\n||".$l[1].'|';
91 91
 		list($entete, $corps) = explode("\n", $corps, 2);
92 92
 	}
93 93
 	// si premiere colonne vide, le raccourci doit quand meme produire <th...
94 94
 	if ($entete[0] == $sep) {
95
-		$entete = ' ' . $entete;
95
+		$entete = ' '.$entete;
96 96
 	}
97 97
 
98 98
 	$lignes = explode("\n", $corps);
Please login to merge, or discard this patch.
ecrire/inc/utils.php 3 patches
Spacing   +121 added lines, -123 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	if (strlen($dossier) and substr($dossier, -1) != '/') {
54 54
 		$dossier .= '/';
55 55
 	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
56
+	$f = str_replace('/', '_', $dossier).$nom;
57 57
 
58 58
 	if (function_exists($f)) {
59 59
 		return $f;
60 60
 	}
61
-	if (function_exists($g = $f . '_dist')) {
61
+	if (function_exists($g = $f.'_dist')) {
62 62
 		return $g;
63 63
 	}
64 64
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81 81
 	if (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+		!$inc = include_spip($dossier.($d = strtolower($nom)))
83 83
 		// si le fichier truc/machin/nom.php n'existe pas,
84 84
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85 85
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
+	spip_log("fonction $nom ($f ou $g) indisponible".
102 102
 		($inc ? '' : " (fichier $d absent de $dossier)"));
103 103
 
104 104
 	include_spip('inc/minipres');
105 105
 	echo minipres(
106 106
 		_T('forum_titre_erreur'),
107
-		_T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
-		['all_inline' => true,'status' => 404]
107
+		_T('fichier_introuvable', ['fichier' => '<b>'.spip_htmlentities($d).'</b>']),
108
+		['all_inline' => true, 'status' => 404]
109 109
 	);
110 110
 	exit;
111 111
 }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  *     - string : chemin du fichier trouvé
152 152
  **/
153 153
 function include_spip($f, $include = true) {
154
-	return find_in_path($f . '.php', '', $include);
154
+	return find_in_path($f.'.php', '', $include);
155 155
 }
156 156
 
157 157
 /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  *     - string : chemin du fichier trouvé
172 172
  **/
173 173
 function require_spip($f) {
174
-	return find_in_path($f . '.php', '', 'required');
174
+	return find_in_path($f.'.php', '', 'required');
175 175
 }
176 176
 
177 177
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		// donc il faut l'inclure "en globals"
189 189
 		if ($f = find_in_path('mes_fonctions.php')) {
190 190
 			global $dossier_squelettes;
191
-			include_once(_ROOT_CWD . $f);
191
+			include_once(_ROOT_CWD.$f);
192 192
 		}
193 193
 
194 194
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	// appliquer notre fonction si elle existe
296
-	$fonc = 'execute_pipeline_' . strtolower($action);
296
+	$fonc = 'execute_pipeline_'.strtolower($action);
297 297
 	if (function_exists($fonc)) {
298 298
 		$val = $fonc($val);
299 299
 	} // plantage ?
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 function spip_log($message = null, $name = null) {
359 359
 	static $pre = [];
360 360
 	static $log;
361
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
361
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
362 362
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
363 363
 		$logname = null;
364 364
 	}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		if (!is_string($message)) {
387 387
 			$message = print_r($message, true);
388 388
 		}
389
-		$log($pre[$niveau] . ' ' . $message, $logname);
389
+		$log($pre[$niveau].' '.$message, $logname);
390 390
 	}
391 391
 }
392 392
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		$a = './';
588 588
 	}
589 589
 
590
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
590
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
591 591
 	$ajouts = array_flip(explode('|', $c));
592 592
 	$u = is_array($v) ? $v : rawurlencode($v);
593 593
 	$testv = (is_array($v) ? count($v) : strlen($v));
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 			// Ajout. Pour une variable, remplacer au meme endroit,
615 615
 			// pour un tableau ce sera fait dans la prochaine boucle
616 616
 			elseif (substr($r[1], -2) != '[]') {
617
-				$url[$n] = $r[1] . '=' . $u;
617
+				$url[$n] = $r[1].'='.$u;
618 618
 				unset($ajouts[$r[1]]);
619 619
 			}
620 620
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -635,11 +635,11 @@  discard block
 block discarded – undo
635 635
 	} elseif ($testv) {
636 636
 		foreach ($ajouts as $k => $n) {
637 637
 			if (!is_array($v)) {
638
-				$url[] = $k . '=' . $u;
638
+				$url[] = $k.'='.$u;
639 639
 			} else {
640
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
640
+				$id = (substr($k, -2) == '[]') ? $k : ($k.'[]');
641 641
 				foreach ($v as $w) {
642
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
642
+					$url[] = $id.'='.(is_array($w) ? 'Array' : $w);
643 643
 				}
644 644
 			}
645 645
 		}
@@ -650,10 +650,10 @@  discard block
 block discarded – undo
650 650
 
651 651
 	// recomposer l'adresse
652 652
 	if ($url) {
653
-		$a .= '?' . join($sep, $url);
653
+		$a .= '?'.join($sep, $url);
654 654
 	}
655 655
 
656
-	return $a . $ancre;
656
+	return $a.$ancre;
657 657
 }
658 658
 
659 659
 /**
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 			translitteration($ancre)
686 686
 		);
687 687
 	}
688
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
688
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
689 689
 }
690 690
 
691 691
 /**
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
  * @return bool
802 802
  */
803 803
 function test_plugin_actif($plugin) {
804
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
804
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
805 805
 }
806 806
 
807 807
 /**
@@ -871,8 +871,7 @@  discard block
 block discarded – undo
871 871
 			$text = str_replace(
872 872
 				'_',
873 873
 				' ',
874
-				(($n = strpos($text, ':')) === false ? $texte :
875
-				substr($texte, $n + 1))
874
+				(($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1))
876 875
 			);
877 876
 		}
878 877
 		$o['class'] = null;
@@ -934,7 +933,7 @@  discard block
 block discarded – undo
934 933
 					$value = interdire_scripts($value, -1);
935 934
 				}
936 935
 				if (!empty($options['class'])) {
937
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
936
+					$value = "<span class='".$options['class']."'>$value</span>";
938 937
 				}
939 938
 				$text = str_replace("@$name@", $value, $text);
940 939
 				unset($args[$name]);
@@ -943,7 +942,7 @@  discard block
 block discarded – undo
943 942
 		// Si des variables n'ont pas ete inserees, le signaler
944 943
 		// (chaines de langues pas a jour)
945 944
 		if ($args) {
946
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
945
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
947 946
 		}
948 947
 	}
949 948
 
@@ -967,7 +966,7 @@  discard block
 block discarded – undo
967 966
 function joli_repertoire($rep) {
968 967
 	$a = substr($rep, 0, 1);
969 968
 	if ($a <> '.' and $a <> '/') {
970
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
969
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
971 970
 	}
972 971
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
973 972
 
@@ -1021,7 +1020,7 @@  discard block
 block discarded – undo
1021 1020
 			$p -= ($x * 1000);
1022 1021
 		}
1023 1022
 
1024
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1023
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1025 1024
 	}
1026 1025
 }
1027 1026
 
@@ -1089,7 +1088,7 @@  discard block
 block discarded – undo
1089 1088
 	if ($taches and count($taches) and !spip_connect()) {
1090 1089
 		return false;
1091 1090
 	}
1092
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1091
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1093 1092
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1094 1093
 		return $genie($taches);
1095 1094
 	}
@@ -1193,7 +1192,7 @@  discard block
 block discarded – undo
1193 1192
 
1194 1193
 	if ($queue_next_job_time == -1) {
1195 1194
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1196
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1195
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1197 1196
 		}
1198 1197
 		// utiliser un cache memoire si dispo
1199 1198
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1262,8 +1261,8 @@  discard block
 block discarded – undo
1262 1261
 		$src = '';
1263 1262
 	}
1264 1263
 	if ($script) {
1265
-		$script = ("/*<![CDATA[*/\n" .
1266
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1264
+		$script = ("/*<![CDATA[*/\n".
1265
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1267 1266
 			'/*]]>*/');
1268 1267
 	}
1269 1268
 	if ($noscript) {
@@ -1349,13 +1348,13 @@  discard block
 block discarded – undo
1349 1348
 	if ($path_base == null) {
1350 1349
 		// Chemin standard depuis l'espace public
1351 1350
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1352
-			_DIR_RACINE . ':' .
1353
-			_DIR_RACINE . 'squelettes-dist/:' .
1354
-			_DIR_RACINE . 'prive/:' .
1351
+			_DIR_RACINE.':'.
1352
+			_DIR_RACINE.'squelettes-dist/:'.
1353
+			_DIR_RACINE.'prive/:'.
1355 1354
 			_DIR_RESTREINT;
1356 1355
 		// Ajouter squelettes/
1357
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1358
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1356
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1357
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1359 1358
 		}
1360 1359
 		foreach (explode(':', $path) as $dir) {
1361 1360
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1367,7 +1366,7 @@  discard block
 block discarded – undo
1367 1366
 		// Et le(s) dossier(s) des squelettes nommes
1368 1367
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1369 1368
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1370
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1369
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1371 1370
 			}
1372 1371
 		}
1373 1372
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1378,7 +1377,7 @@  discard block
 block discarded – undo
1378 1377
 
1379 1378
 	if (is_array($dir_path) or strlen($dir_path)) {
1380 1379
 		$tete = '';
1381
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1380
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1382 1381
 			$tete = array_shift($path_base);
1383 1382
 		}
1384 1383
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1399,7 +1398,7 @@  discard block
 block discarded – undo
1399 1398
 	// Et le(s) dossier(s) des squelettes nommes
1400 1399
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1401 1400
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1402
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1401
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1403 1402
 		}
1404 1403
 	}
1405 1404
 
@@ -1470,14 +1469,14 @@  discard block
 block discarded – undo
1470 1469
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1471 1470
 	if (
1472 1471
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1473
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1472
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1474 1473
 		and $f = find_in_theme("$file_svg_generique")
1475 1474
 	) {
1476
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1475
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1477 1476
 			return $themefiles["$subdir$file"] = $fsize;
1478 1477
 		}
1479 1478
 		else {
1480
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1479
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1481 1480
 		}
1482 1481
 	}
1483 1482
 
@@ -1487,7 +1486,7 @@  discard block
 block discarded – undo
1487 1486
 			return $themefiles["$subdir$file"] = $f;
1488 1487
 		}
1489 1488
 	}
1490
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1489
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1491 1490
 
1492 1491
 	return $themefiles["$subdir$file"] = '';
1493 1492
 }
@@ -1595,8 +1594,8 @@  discard block
 block discarded – undo
1595 1594
 			return false;
1596 1595
 		}
1597 1596
 		if ($include and !isset($inc[$dirname][$file])) {
1598
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1599
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1597
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1598
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1600 1599
 		}
1601 1600
 
1602 1601
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1609,14 +1608,14 @@  discard block
 block discarded – undo
1609 1608
 	}
1610 1609
 
1611 1610
 	foreach (creer_chemin() as $dir) {
1612
-		if (!isset($dirs[$a = $dir . $dirname])) {
1613
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1611
+		if (!isset($dirs[$a = $dir.$dirname])) {
1612
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1614 1613
 		}
1615 1614
 		if ($dirs[$a]) {
1616
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1615
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1617 1616
 				if ($include and !isset($inc[$dirname][$file])) {
1618
-					include_once _ROOT_CWD . $a;
1619
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1617
+					include_once _ROOT_CWD.$a;
1618
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1620 1619
 				}
1621 1620
 				if (!defined('_SAUVER_CHEMIN')) {
1622 1621
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1626,7 +1625,7 @@  discard block
 block discarded – undo
1626 1625
 					define('_SAUVER_CHEMIN', true);
1627 1626
 				}
1628 1627
 
1629
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1628
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1630 1629
 			}
1631 1630
 		}
1632 1631
 	}
@@ -1652,7 +1651,7 @@  discard block
 block discarded – undo
1652 1651
 		define('_SAUVER_CHEMIN', true);
1653 1652
 	}
1654 1653
 
1655
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1654
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1656 1655
 }
1657 1656
 
1658 1657
 function clear_path_cache() {
@@ -1722,12 +1721,12 @@  discard block
 block discarded – undo
1722 1721
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1723 1722
 	// on a pas encore inclus flock.php
1724 1723
 	if (!function_exists('preg_files')) {
1725
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1724
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1726 1725
 	}
1727 1726
 
1728 1727
 	// Parcourir le chemin
1729 1728
 	foreach (creer_chemin() as $d) {
1730
-		$f = $d . $dir;
1729
+		$f = $d.$dir;
1731 1730
 		if (@is_dir($f)) {
1732 1731
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1733 1732
 			foreach ($liste as $chemin) {
@@ -1838,7 +1837,7 @@  discard block
 block discarded – undo
1838 1837
 		return $res;
1839 1838
 	}
1840 1839
 	// Sinon c'est un raccourci ou compat SPIP < 2
1841
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1840
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1842 1841
 		if (!function_exists($f .= '_dist')) {
1843 1842
 			$f = '';
1844 1843
 		}
@@ -1847,8 +1846,8 @@  discard block
 block discarded – undo
1847 1846
 		$url = $f($id, $args, $ancre);
1848 1847
 		if (strlen($args)) {
1849 1848
 			$url .= strstr($url, '?')
1850
-				? '&amp;' . $args
1851
-				: '?' . $args;
1849
+				? '&amp;'.$args
1850
+				: '?'.$args;
1852 1851
 		}
1853 1852
 
1854 1853
 		return $url;
@@ -1879,8 +1878,8 @@  discard block
 block discarded – undo
1879 1878
 	include_spip('base/connect_sql');
1880 1879
 	$id_type = id_table_objet($entite, $public);
1881 1880
 
1882
-	return _DIR_RACINE . get_spip_script('./')
1883
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1881
+	return _DIR_RACINE.get_spip_script('./')
1882
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1884 1883
 	. (!$args ? '' : "&$args")
1885 1884
 	. (!$ancre ? '' : "#$ancre");
1886 1885
 }
@@ -2034,7 +2033,7 @@  discard block
 block discarded – undo
2034 2033
 				!empty($_SERVER['QUERY_STRING'])
2035 2034
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2036 2035
 			) {
2037
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2036
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2038 2037
 			}
2039 2038
 		}
2040 2039
 	}
@@ -2069,9 +2068,9 @@  discard block
 block discarded – undo
2069 2068
 		array_shift($myself);
2070 2069
 		$myself = implode('/', $myself);
2071 2070
 	}
2072
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2071
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2073 2072
 
2074
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2073
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2075 2074
 
2076 2075
 	return $url;
2077 2076
 }
@@ -2109,17 +2108,17 @@  discard block
 block discarded – undo
2109 2108
  **/
2110 2109
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2111 2110
 	if (!$rel) {
2112
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2111
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2113 2112
 	} else {
2114 2113
 		if (!is_string($rel)) {
2115 2114
 			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2116
-				('./' . _SPIP_ECRIRE_SCRIPT);
2115
+				('./'._SPIP_ECRIRE_SCRIPT);
2117 2116
 		}
2118 2117
 	}
2119 2118
 
2120 2119
 	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2121 2120
 	if ($script and ($script <> 'accueil' or $rel)) {
2122
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2121
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2123 2122
 	} elseif ($args) {
2124 2123
 		$args = "?$args";
2125 2124
 	}
@@ -2127,7 +2126,7 @@  discard block
 block discarded – undo
2127 2126
 		$args .= "#$ancre";
2128 2127
 	}
2129 2128
 
2130
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2129
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2131 2130
 }
2132 2131
 
2133 2132
 //
@@ -2197,25 +2196,25 @@  discard block
 block discarded – undo
2197 2196
 		if (is_array($args)) {
2198 2197
 			$r = '';
2199 2198
 			foreach ($args as $k => $v) {
2200
-				$r .= '&' . $k . '=' . $v;
2199
+				$r .= '&'.$k.'='.$v;
2201 2200
 			}
2202 2201
 			$args = substr($r, 1);
2203 2202
 		}
2204 2203
 		$action .=
2205
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2204
+			(strpos($action, '?') !== false ? '&' : '?').$args;
2206 2205
 	}
2207 2206
 	if (!$no_entities) {
2208 2207
 		$action = quote_amp($action);
2209 2208
 	}
2210 2209
 
2211 2210
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2212
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2211
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2213 2212
 }
2214 2213
 
2215 2214
 // https://code.spip.net/@generer_url_prive
2216 2215
 function generer_url_prive($script, $args = '', $no_entities = false) {
2217 2216
 
2218
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2217
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2219 2218
 }
2220 2219
 
2221 2220
 // Pour les formulaires en methode POST,
@@ -2250,8 +2249,7 @@  discard block
 block discarded – undo
2250 2249
 	. "><div>\n"
2251 2250
 	. "<input type='hidden' name='exec' value='$script1' />"
2252 2251
 	. $corps
2253
-	. (!$submit ? '' :
2254
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2252
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2255 2253
 	. "</div></form>\n";
2256 2254
 }
2257 2255
 
@@ -2276,14 +2274,14 @@  discard block
 block discarded – undo
2276 2274
 		? generer_url_ecrire(_request('exec'))
2277 2275
 		: generer_url_public();
2278 2276
 
2279
-	return "\n<form action='" .
2280
-	$h .
2281
-	"'" .
2282
-	$atts .
2283
-	">\n" .
2284
-	'<div>' .
2285
-	"\n<input type='hidden' name='action' value='$script' />" .
2286
-	$corps .
2277
+	return "\n<form action='".
2278
+	$h.
2279
+	"'".
2280
+	$atts.
2281
+	">\n".
2282
+	'<div>'.
2283
+	"\n<input type='hidden' name='action' value='$script' />".
2284
+	$corps.
2287 2285
 	'</div></form>';
2288 2286
 }
2289 2287
 
@@ -2311,7 +2309,7 @@  discard block
 block discarded – undo
2311 2309
 		: generer_url_public('', '', false, false);
2312 2310
 	$url = parametre_url($url, 'action', $script);
2313 2311
 	if ($args) {
2314
-		$url .= quote_amp('&' . $args);
2312
+		$url .= quote_amp('&'.$args);
2315 2313
 	}
2316 2314
 
2317 2315
 	if ($no_entities) {
@@ -2361,17 +2359,17 @@  discard block
 block discarded – undo
2361 2359
 
2362 2360
 	// le nom du repertoire plugins/ activables/desactivables
2363 2361
 	if (!defined('_DIR_PLUGINS')) {
2364
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2362
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2365 2363
 	}
2366 2364
 
2367 2365
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2368 2366
 	if (!defined('_DIR_PLUGINS_DIST')) {
2369
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2367
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2370 2368
 	}
2371 2369
 
2372 2370
 	// le nom du repertoire des librairies
2373 2371
 	if (!defined('_DIR_LIB')) {
2374
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2372
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2375 2373
 	}
2376 2374
 
2377 2375
 	if (!defined('_DIR_IMG')) {
@@ -2381,29 +2379,29 @@  discard block
 block discarded – undo
2381 2379
 		define('_DIR_LOGOS', $pa);
2382 2380
 	}
2383 2381
 	if (!defined('_DIR_IMG_ICONES')) {
2384
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2382
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2385 2383
 	}
2386 2384
 
2387 2385
 	if (!defined('_DIR_DUMP')) {
2388
-		define('_DIR_DUMP', $ti . 'dump/');
2386
+		define('_DIR_DUMP', $ti.'dump/');
2389 2387
 	}
2390 2388
 	if (!defined('_DIR_SESSIONS')) {
2391
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2389
+		define('_DIR_SESSIONS', $ti.'sessions/');
2392 2390
 	}
2393 2391
 	if (!defined('_DIR_TRANSFERT')) {
2394
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2392
+		define('_DIR_TRANSFERT', $ti.'upload/');
2395 2393
 	}
2396 2394
 	if (!defined('_DIR_CACHE')) {
2397
-		define('_DIR_CACHE', $ti . 'cache/');
2395
+		define('_DIR_CACHE', $ti.'cache/');
2398 2396
 	}
2399 2397
 	if (!defined('_DIR_CACHE_XML')) {
2400
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2398
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2401 2399
 	}
2402 2400
 	if (!defined('_DIR_SKELS')) {
2403
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2401
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2404 2402
 	}
2405 2403
 	if (!defined('_DIR_AIDE')) {
2406
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2404
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2407 2405
 	}
2408 2406
 	if (!defined('_DIR_TMP')) {
2409 2407
 		define('_DIR_TMP', $ti);
@@ -2432,27 +2430,27 @@  discard block
 block discarded – undo
2432 2430
 	// Declaration des fichiers
2433 2431
 
2434 2432
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2435
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2433
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2436 2434
 	}
2437 2435
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2438
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2436
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2439 2437
 	}
2440 2438
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2441
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2439
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2442 2440
 	}
2443 2441
 	if (!defined('_CACHE_PIPELINES')) {
2444
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2442
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2445 2443
 	}
2446 2444
 	if (!defined('_CACHE_CHEMIN')) {
2447
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2445
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2448 2446
 	}
2449 2447
 
2450 2448
 	# attention .php obligatoire pour ecrire_fichier_securise
2451 2449
 	if (!defined('_FILE_META')) {
2452
-		define('_FILE_META', $ti . 'meta_cache.php');
2450
+		define('_FILE_META', $ti.'meta_cache.php');
2453 2451
 	}
2454 2452
 	if (!defined('_DIR_LOG')) {
2455
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2453
+		define('_DIR_LOG', _DIR_TMP.'log/');
2456 2454
 	}
2457 2455
 	if (!defined('_FILE_LOG')) {
2458 2456
 		define('_FILE_LOG', 'spip');
@@ -2469,8 +2467,8 @@  discard block
 block discarded – undo
2469 2467
 	if (!defined('_FILE_CONNECT')) {
2470 2468
 		define(
2471 2469
 			'_FILE_CONNECT',
2472
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2473
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2470
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2471
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2474 2472
 			: false))
2475 2473
 		);
2476 2474
 	}
@@ -2482,7 +2480,7 @@  discard block
 block discarded – undo
2482 2480
 	if (!defined('_FILE_CHMOD')) {
2483 2481
 		define(
2484 2482
 			'_FILE_CHMOD',
2485
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2483
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2486 2484
 			: false)
2487 2485
 		);
2488 2486
 	}
@@ -2495,10 +2493,10 @@  discard block
 block discarded – undo
2495 2493
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2496 2494
 	}
2497 2495
 	if (!defined('_FILE_CONNECT_TMP')) {
2498
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2496
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2499 2497
 	}
2500 2498
 	if (!defined('_FILE_CHMOD_TMP')) {
2501
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2499
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2502 2500
 	}
2503 2501
 
2504 2502
 	// Definition des droits d'acces en ecriture
@@ -2516,13 +2514,13 @@  discard block
 block discarded – undo
2516 2514
 		define('_DEFAULT_CHARSET', 'utf-8');
2517 2515
 	}
2518 2516
 	if (!defined('_ROOT_PLUGINS')) {
2519
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2517
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2520 2518
 	}
2521 2519
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2522
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2520
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2523 2521
 	}
2524 2522
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2525
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2523
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2526 2524
 	}
2527 2525
 
2528 2526
 	// La taille des Log
@@ -2559,7 +2557,7 @@  discard block
 block discarded – undo
2559 2557
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2560 2558
 	// pour le rendre surchargeable, on va provoquer un reecriture
2561 2559
 	// systematique du noyau ou une baisse de perfs => a etudier)
2562
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2560
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2563 2561
 
2564 2562
 	// charger tout de suite le path et son cache
2565 2563
 	load_path_cache();
@@ -2607,7 +2605,7 @@  discard block
 block discarded – undo
2607 2605
 			!empty($_SERVER['QUERY_STRING'])
2608 2606
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2609 2607
 		) {
2610
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2608
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2611 2609
 		}
2612 2610
 	}
2613 2611
 
@@ -2643,7 +2641,7 @@  discard block
 block discarded – undo
2643 2641
 		) {
2644 2642
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2645 2643
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2646
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2644
+				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/';
2647 2645
 			} else {
2648 2646
 				$uri_ref = '';
2649 2647
 			}
@@ -2733,7 +2731,7 @@  discard block
 block discarded – undo
2733 2731
 	}
2734 2732
 	if (!defined('_CACHE_RUBRIQUES')) {
2735 2733
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2736
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2734
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2737 2735
 	}
2738 2736
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2739 2737
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -2837,7 +2835,7 @@  discard block
 block discarded – undo
2837 2835
 					$memory *= 1024;
2838 2836
 			}
2839 2837
 			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2840
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2838
+				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
2841 2839
 				if (trim(ini_get('memory_limit')) != $m) {
2842 2840
 					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2843 2841
 						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
@@ -2988,7 +2986,7 @@  discard block
 block discarded – undo
2988 2986
 					}
2989 2987
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
2990 2988
 						spip_log($GLOBALS['visiteur_session']['nom']
2991
-							. ' ' . _VAR_MODE);
2989
+							. ' '._VAR_MODE);
2992 2990
 					}
2993 2991
 				} // pas autorise ?
2994 2992
 				else {
@@ -3003,7 +3001,7 @@  discard block
 block discarded – undo
3003 3001
 						if (strpos($self, 'page=login') === false) {
3004 3002
 							include_spip('inc/headers');
3005 3003
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3006
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3004
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3007 3005
 						}
3008 3006
 					}
3009 3007
 					// sinon tant pis
@@ -3047,10 +3045,10 @@  discard block
 block discarded – undo
3047 3045
 	// mais on risque de perturber des plugins en initialisant trop tot
3048 3046
 	// certaines constantes
3049 3047
 	@spip_initialisation_core(
3050
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3051
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3052
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3053
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3048
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3049
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3050
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3051
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3054 3052
 	);
3055 3053
 
3056 3054
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3083,7 +3081,7 @@  discard block
 block discarded – undo
3083 3081
 	}
3084 3082
 
3085 3083
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3086
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3084
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3087 3085
 		$session = charger_fonction('session', 'inc');
3088 3086
 		if ($session()) {
3089 3087
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3163,7 +3161,7 @@  discard block
 block discarded – undo
3163 3161
 			'definir_session',
3164 3162
 			$GLOBALS['visiteur_session']
3165 3163
 				? serialize($GLOBALS['visiteur_session'])
3166
-				. '_' . @$_COOKIE['spip_session']
3164
+				. '_'.@$_COOKIE['spip_session']
3167 3165
 				: ''
3168 3166
 		);
3169 3167
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3319,11 +3317,11 @@  discard block
 block discarded – undo
3319 3317
 	$GLOBALS['_INC_PUBLIC']++;
3320 3318
 
3321 3319
 	// fix #4235
3322
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3320
+	$cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3323 3321
 
3324 3322
 
3325 3323
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3326
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3324
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3327 3325
 
3328 3326
 		$page = evaluer_fond($f, $contexte, $connect);
3329 3327
 		if ($page === '') {
@@ -3408,7 +3406,7 @@  discard block
 block discarded – undo
3408 3406
  * @return array|string
3409 3407
  */
3410 3408
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3411
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3409
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3412 3410
 	if (!$pathinfo) {
3413 3411
 		return $f;
3414 3412
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -364,8 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 	if (!isset($regs[2])) {
366 366
 		$niveau = _LOG_INFO;
367
-	}
368
-	else {
367
+	} else {
369 368
 		$niveau = intval($regs[2]);
370 369
 	}
371 370
 
@@ -1475,8 +1474,7 @@  discard block
 block discarded – undo
1475 1474
 	) {
1476 1475
 		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1477 1476
 			return $themefiles["$subdir$file"] = $fsize;
1478
-		}
1479
-		else {
1477
+		} else {
1480 1478
 			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1481 1479
 		}
1482 1480
 	}
@@ -3496,8 +3494,7 @@  discard block
 block discarded – undo
3496 3494
 		if (!in_array('svg', $formats)) {
3497 3495
 			$formats[] = 'svg';
3498 3496
 		}
3499
-	}
3500
-	else {
3497
+	} else {
3501 3498
 		$formats = array_diff($formats, ['svg']);
3502 3499
 	}
3503 3500
 	return $formats;
Please login to merge, or discard this patch.
Indentation   +2228 added lines, -2229 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
 
@@ -48,66 +48,66 @@  discard block
 block discarded – undo
48 48
  *     Nom de la fonction, ou false.
49 49
  */
50 50
 function charger_fonction($nom, $dossier = 'exec', $continue = false) {
51
-	static $echecs = [];
52
-
53
-	if (strlen($dossier) and substr($dossier, -1) != '/') {
54
-		$dossier .= '/';
55
-	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
57
-
58
-	if (function_exists($f)) {
59
-		return $f;
60
-	}
61
-	if (function_exists($g = $f . '_dist')) {
62
-		return $g;
63
-	}
64
-
65
-	if (isset($echecs[$f])) {
66
-		return $echecs[$f];
67
-	}
68
-	// Sinon charger le fichier de declaration si plausible
69
-
70
-	if (!preg_match(',^\w+$,', $f)) {
71
-		if ($continue) {
72
-			return false;
73
-		} //appel interne, on passe
74
-		include_spip('inc/minipres');
75
-		echo minipres();
76
-		exit;
77
-	}
78
-
79
-	// passer en minuscules (cf les balises de formulaires)
80
-	// et inclure le fichier
81
-	if (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
83
-		// si le fichier truc/machin/nom.php n'existe pas,
84
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
-	) {
87
-		include_spip(substr($dossier, 0, -1));
88
-	}
89
-	if (function_exists($f)) {
90
-		return $f;
91
-	}
92
-	if (function_exists($g)) {
93
-		return $g;
94
-	}
95
-
96
-	if ($continue) {
97
-		return $echecs[$f] = false;
98
-	}
99
-
100
-	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
102
-		($inc ? '' : " (fichier $d absent de $dossier)"));
103
-
104
-	include_spip('inc/minipres');
105
-	echo minipres(
106
-		_T('forum_titre_erreur'),
107
-		_T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
-		['all_inline' => true,'status' => 404]
109
-	);
110
-	exit;
51
+    static $echecs = [];
52
+
53
+    if (strlen($dossier) and substr($dossier, -1) != '/') {
54
+        $dossier .= '/';
55
+    }
56
+    $f = str_replace('/', '_', $dossier) . $nom;
57
+
58
+    if (function_exists($f)) {
59
+        return $f;
60
+    }
61
+    if (function_exists($g = $f . '_dist')) {
62
+        return $g;
63
+    }
64
+
65
+    if (isset($echecs[$f])) {
66
+        return $echecs[$f];
67
+    }
68
+    // Sinon charger le fichier de declaration si plausible
69
+
70
+    if (!preg_match(',^\w+$,', $f)) {
71
+        if ($continue) {
72
+            return false;
73
+        } //appel interne, on passe
74
+        include_spip('inc/minipres');
75
+        echo minipres();
76
+        exit;
77
+    }
78
+
79
+    // passer en minuscules (cf les balises de formulaires)
80
+    // et inclure le fichier
81
+    if (
82
+        !$inc = include_spip($dossier . ($d = strtolower($nom)))
83
+        // si le fichier truc/machin/nom.php n'existe pas,
84
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
+    ) {
87
+        include_spip(substr($dossier, 0, -1));
88
+    }
89
+    if (function_exists($f)) {
90
+        return $f;
91
+    }
92
+    if (function_exists($g)) {
93
+        return $g;
94
+    }
95
+
96
+    if ($continue) {
97
+        return $echecs[$f] = false;
98
+    }
99
+
100
+    // Echec : message d'erreur
101
+    spip_log("fonction $nom ($f ou $g) indisponible" .
102
+        ($inc ? '' : " (fichier $d absent de $dossier)"));
103
+
104
+    include_spip('inc/minipres');
105
+    echo minipres(
106
+        _T('forum_titre_erreur'),
107
+        _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
+        ['all_inline' => true,'status' => 404]
109
+    );
110
+    exit;
111 111
 }
112 112
 
113 113
 /**
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
  * @return bool
118 118
  */
119 119
 function include_once_check($file) {
120
-	if (file_exists($file)) {
121
-		include_once $file;
120
+    if (file_exists($file)) {
121
+        include_once $file;
122 122
 
123
-		return true;
124
-	}
125
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
126
-	$crash = ($crash ? $crash : []);
127
-	$crash[$file] = true;
128
-	ecrire_meta('message_crash_plugins', serialize($crash));
123
+        return true;
124
+    }
125
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
126
+    $crash = ($crash ? $crash : []);
127
+    $crash[$file] = true;
128
+    ecrire_meta('message_crash_plugins', serialize($crash));
129 129
 
130
-	return false;
130
+    return false;
131 131
 }
132 132
 
133 133
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  *     - string : chemin du fichier trouvé
152 152
  **/
153 153
 function include_spip($f, $include = true) {
154
-	return find_in_path($f . '.php', '', $include);
154
+    return find_in_path($f . '.php', '', $include);
155 155
 }
156 156
 
157 157
 /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  *     - string : chemin du fichier trouvé
172 172
  **/
173 173
 function require_spip($f) {
174
-	return find_in_path($f . '.php', '', 'required');
174
+    return find_in_path($f . '.php', '', 'required');
175 175
 }
176 176
 
177 177
 
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
181 181
  */
182 182
 function include_fichiers_fonctions() {
183
-	static $done = false;
184
-	if (!$done) {
185
-		include_spip('inc/lang');
186
-
187
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
188
-		// donc il faut l'inclure "en globals"
189
-		if ($f = find_in_path('mes_fonctions.php')) {
190
-			global $dossier_squelettes;
191
-			include_once(_ROOT_CWD . $f);
192
-		}
193
-
194
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
195
-			// chargement optimise precompile
196
-			include_once(_CACHE_PLUGINS_FCT);
197
-		}
198
-		if (test_espace_prive()) {
199
-			include_spip('inc/filtres_ecrire');
200
-		}
201
-		include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
202
-		$done = true;
203
-	}
183
+    static $done = false;
184
+    if (!$done) {
185
+        include_spip('inc/lang');
186
+
187
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
188
+        // donc il faut l'inclure "en globals"
189
+        if ($f = find_in_path('mes_fonctions.php')) {
190
+            global $dossier_squelettes;
191
+            include_once(_ROOT_CWD . $f);
192
+        }
193
+
194
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
195
+            // chargement optimise precompile
196
+            include_once(_CACHE_PLUGINS_FCT);
197
+        }
198
+        if (test_espace_prive()) {
199
+            include_spip('inc/filtres_ecrire');
200
+        }
201
+        include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
202
+        $done = true;
203
+    }
204 204
 }
205 205
 
206 206
 /**
@@ -226,23 +226,23 @@  discard block
 block discarded – undo
226 226
  *     Les paramètres du pipeline modifiés
227 227
  **/
228 228
 function minipipe($fonc, &$val) {
229
-	// fonction
230
-	if (function_exists($fonc)) {
231
-		$val = call_user_func($fonc, $val);
232
-	} // Class::Methode
233
-	else {
234
-		if (
235
-			preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
236
-			and $methode = [$regs[1], $regs[2]]
237
-			and is_callable($methode)
238
-		) {
239
-			$val = call_user_func($methode, $val);
240
-		} else {
241
-			spip_log("Erreur - '$fonc' non definie !");
242
-		}
243
-	}
244
-
245
-	return $val;
229
+    // fonction
230
+    if (function_exists($fonc)) {
231
+        $val = call_user_func($fonc, $val);
232
+    } // Class::Methode
233
+    else {
234
+        if (
235
+            preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
236
+            and $methode = [$regs[1], $regs[2]]
237
+            and is_callable($methode)
238
+        ) {
239
+            $val = call_user_func($methode, $val);
240
+        } else {
241
+            spip_log("Erreur - '$fonc' non definie !");
242
+        }
243
+    }
244
+
245
+    return $val;
246 246
 }
247 247
 
248 248
 /**
@@ -273,46 +273,46 @@  discard block
 block discarded – undo
273 273
  *     Résultat
274 274
  */
275 275
 function pipeline($action, $val = null) {
276
-	static $charger;
277
-
278
-	// chargement initial des fonctions mises en cache, ou generation du cache
279
-	if (!$charger) {
280
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
281
-			include_spip('inc/plugin');
282
-			// generer les fichiers php precompiles
283
-			// de chargement des plugins et des pipelines
284
-			actualise_plugins_actifs();
285
-			if (!($ok = @is_readable($charger))) {
286
-				spip_log("fichier $charger pas cree");
287
-			}
288
-		}
289
-
290
-		if ($ok) {
291
-			include_once $charger;
292
-		}
293
-	}
294
-
295
-	// appliquer notre fonction si elle existe
296
-	$fonc = 'execute_pipeline_' . strtolower($action);
297
-	if (function_exists($fonc)) {
298
-		$val = $fonc($val);
299
-	} // plantage ?
300
-	else {
301
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
302
-	}
303
-
304
-	// si le flux est une table avec 2 cle args&data
305
-	// on ne ressort du pipe que les donnees dans 'data'
306
-	// array_key_exists pour php 4.1.0
307
-	if (
308
-		is_array($val)
309
-		and count($val) == 2
310
-		and (array_key_exists('data', $val))
311
-	) {
312
-		$val = $val['data'];
313
-	}
314
-
315
-	return $val;
276
+    static $charger;
277
+
278
+    // chargement initial des fonctions mises en cache, ou generation du cache
279
+    if (!$charger) {
280
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
281
+            include_spip('inc/plugin');
282
+            // generer les fichiers php precompiles
283
+            // de chargement des plugins et des pipelines
284
+            actualise_plugins_actifs();
285
+            if (!($ok = @is_readable($charger))) {
286
+                spip_log("fichier $charger pas cree");
287
+            }
288
+        }
289
+
290
+        if ($ok) {
291
+            include_once $charger;
292
+        }
293
+    }
294
+
295
+    // appliquer notre fonction si elle existe
296
+    $fonc = 'execute_pipeline_' . strtolower($action);
297
+    if (function_exists($fonc)) {
298
+        $val = $fonc($val);
299
+    } // plantage ?
300
+    else {
301
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
302
+    }
303
+
304
+    // si le flux est une table avec 2 cle args&data
305
+    // on ne ressort du pipe que les donnees dans 'data'
306
+    // array_key_exists pour php 4.1.0
307
+    if (
308
+        is_array($val)
309
+        and count($val) == 2
310
+        and (array_key_exists('data', $val))
311
+    ) {
312
+        $val = $val['data'];
313
+    }
314
+
315
+    return $val;
316 316
 }
317 317
 
318 318
 /**
@@ -356,38 +356,38 @@  discard block
 block discarded – undo
356 356
  *     paramètre est planté pour cause de compatibilité ascendante.
357 357
  */
358 358
 function spip_log($message = null, $name = null) {
359
-	static $pre = [];
360
-	static $log;
361
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
362
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
363
-		$logname = null;
364
-	}
365
-	if (!isset($regs[2])) {
366
-		$niveau = _LOG_INFO;
367
-	}
368
-	else {
369
-		$niveau = intval($regs[2]);
370
-	}
371
-
372
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
373
-		if (!$pre) {
374
-			$pre = [
375
-				_LOG_HS => 'HS:',
376
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
377
-				_LOG_CRITIQUE => 'CRITIQUE:',
378
-				_LOG_ERREUR => 'ERREUR:',
379
-				_LOG_AVERTISSEMENT => 'WARNING:',
380
-				_LOG_INFO_IMPORTANTE => '!INFO:',
381
-				_LOG_INFO => 'info:',
382
-				_LOG_DEBUG => 'debug:'
383
-			];
384
-			$log = charger_fonction('log', 'inc');
385
-		}
386
-		if (!is_string($message)) {
387
-			$message = print_r($message, true);
388
-		}
389
-		$log($pre[$niveau] . ' ' . $message, $logname);
390
-	}
359
+    static $pre = [];
360
+    static $log;
361
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
362
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
363
+        $logname = null;
364
+    }
365
+    if (!isset($regs[2])) {
366
+        $niveau = _LOG_INFO;
367
+    }
368
+    else {
369
+        $niveau = intval($regs[2]);
370
+    }
371
+
372
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
373
+        if (!$pre) {
374
+            $pre = [
375
+                _LOG_HS => 'HS:',
376
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
377
+                _LOG_CRITIQUE => 'CRITIQUE:',
378
+                _LOG_ERREUR => 'ERREUR:',
379
+                _LOG_AVERTISSEMENT => 'WARNING:',
380
+                _LOG_INFO_IMPORTANTE => '!INFO:',
381
+                _LOG_INFO => 'info:',
382
+                _LOG_DEBUG => 'debug:'
383
+            ];
384
+            $log = charger_fonction('log', 'inc');
385
+        }
386
+        if (!is_string($message)) {
387
+            $message = print_r($message, true);
388
+        }
389
+        $log($pre[$niveau] . ' ' . $message, $logname);
390
+    }
391 391
 }
392 392
 
393 393
 /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
  * @param array $opt Tableau d'options
399 399
  **/
400 400
 function journal($phrase, $opt = []) {
401
-	$journal = charger_fonction('journal', 'inc');
402
-	$journal($phrase, $opt);
401
+    $journal = charger_fonction('journal', 'inc');
402
+    $journal($phrase, $opt);
403 403
 }
404 404
 
405 405
 
@@ -418,37 +418,37 @@  discard block
 block discarded – undo
418 418
  **/
419 419
 function _request($var, $c = false) {
420 420
 
421
-	if (is_array($c)) {
422
-		return isset($c[$var]) ? $c[$var] : null;
423
-	}
424
-
425
-	if (isset($_GET[$var])) {
426
-		$a = $_GET[$var];
427
-	} elseif (isset($_POST[$var])) {
428
-		$a = $_POST[$var];
429
-	} else {
430
-		return null;
431
-	}
432
-
433
-	// Si on est en ajax et en POST tout a ete encode
434
-	// via encodeURIComponent, il faut donc repasser
435
-	// dans le charset local...
436
-	if (
437
-		defined('_AJAX')
438
-		and _AJAX
439
-		and isset($GLOBALS['meta']['charset'])
440
-		and $GLOBALS['meta']['charset'] != 'utf-8'
441
-		and is_string($a)
442
-		// check rapide mais pas fiable
443
-		and preg_match(',[\x80-\xFF],', $a)
444
-		// check fiable
445
-		and include_spip('inc/charsets')
446
-		and is_utf8($a)
447
-	) {
448
-		return importer_charset($a, 'utf-8');
449
-	}
450
-
451
-	return $a;
421
+    if (is_array($c)) {
422
+        return isset($c[$var]) ? $c[$var] : null;
423
+    }
424
+
425
+    if (isset($_GET[$var])) {
426
+        $a = $_GET[$var];
427
+    } elseif (isset($_POST[$var])) {
428
+        $a = $_POST[$var];
429
+    } else {
430
+        return null;
431
+    }
432
+
433
+    // Si on est en ajax et en POST tout a ete encode
434
+    // via encodeURIComponent, il faut donc repasser
435
+    // dans le charset local...
436
+    if (
437
+        defined('_AJAX')
438
+        and _AJAX
439
+        and isset($GLOBALS['meta']['charset'])
440
+        and $GLOBALS['meta']['charset'] != 'utf-8'
441
+        and is_string($a)
442
+        // check rapide mais pas fiable
443
+        and preg_match(',[\x80-\xFF],', $a)
444
+        // check fiable
445
+        and include_spip('inc/charsets')
446
+        and is_utf8($a)
447
+    ) {
448
+        return importer_charset($a, 'utf-8');
449
+    }
450
+
451
+    return $a;
452 452
 }
453 453
 
454 454
 
@@ -466,22 +466,22 @@  discard block
 block discarded – undo
466 466
  *     - false sinon
467 467
  **/
468 468
 function set_request($var, $val = null, $c = false) {
469
-	if (is_array($c)) {
470
-		unset($c[$var]);
471
-		if ($val !== null) {
472
-			$c[$var] = $val;
473
-		}
469
+    if (is_array($c)) {
470
+        unset($c[$var]);
471
+        if ($val !== null) {
472
+            $c[$var] = $val;
473
+        }
474 474
 
475
-		return $c;
476
-	}
475
+        return $c;
476
+    }
477 477
 
478
-	unset($_GET[$var]);
479
-	unset($_POST[$var]);
480
-	if ($val !== null) {
481
-		$_GET[$var] = $val;
482
-	}
478
+    unset($_GET[$var]);
479
+    unset($_POST[$var]);
480
+    if ($val !== null) {
481
+        $_GET[$var] = $val;
482
+    }
483 483
 
484
-	return false; # n'affecte pas $c
484
+    return false; # n'affecte pas $c
485 485
 }
486 486
 
487 487
 /**
@@ -501,25 +501,25 @@  discard block
 block discarded – undo
501 501
  * @return array|mixed|string
502 502
  */
503 503
 function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
504
-	if (is_array($value)) {
505
-		if ($key == '*') {
506
-			$key = array_keys($value);
507
-		}
508
-		if (!is_array($key)) {
509
-			$key = [$key];
510
-		}
511
-		foreach ($key as $k) {
512
-			if (!empty($value[$k])) {
513
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
514
-			}
515
-		}
516
-		return $value;
517
-	}
518
-	// si la valeur vient des GET ou POST on la sanitize
519
-	if (!empty($value) and $value == _request($key)) {
520
-		$value = $sanitize_function($value);
521
-	}
522
-	return $value;
504
+    if (is_array($value)) {
505
+        if ($key == '*') {
506
+            $key = array_keys($value);
507
+        }
508
+        if (!is_array($key)) {
509
+            $key = [$key];
510
+        }
511
+        foreach ($key as $k) {
512
+            if (!empty($value[$k])) {
513
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
514
+            }
515
+        }
516
+        return $value;
517
+    }
518
+    // si la valeur vient des GET ou POST on la sanitize
519
+    if (!empty($value) and $value == _request($key)) {
520
+        $value = $sanitize_function($value);
521
+    }
522
+    return $value;
523 523
 }
524 524
 
525 525
 /**
@@ -527,23 +527,22 @@  discard block
 block discarded – undo
527 527
  *
528 528
  * On est sur le web, on exclut certains protocoles,
529 529
  * notamment 'file://', 'php://' et d'autres…
530
-
531 530
  * @param string $url
532 531
  * @return bool
533 532
  */
534 533
 function tester_url_absolue($url) {
535
-	$url = trim($url);
536
-	if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
537
-		if (
538
-			isset($m[1])
539
-			and $p = strtolower(rtrim($m[1], ':'))
540
-			and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
541
-		) {
542
-			return false;
543
-		}
544
-		return true;
545
-	}
546
-	return false;
534
+    $url = trim($url);
535
+    if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
536
+        if (
537
+            isset($m[1])
538
+            and $p = strtolower(rtrim($m[1], ':'))
539
+            and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
540
+        ) {
541
+            return false;
542
+        }
543
+        return true;
544
+    }
545
+    return false;
547 546
 }
548 547
 
549 548
 /**
@@ -565,95 +564,95 @@  discard block
 block discarded – undo
565 564
  * @return string URL
566 565
  */
567 566
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
568
-	// requete erronnee : plusieurs variable dans $c et aucun $v
569
-	if (strpos($c, '|') !== false and is_null($v)) {
570
-		return null;
571
-	}
572
-
573
-	// lever l'#ancre
574
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
575
-		$url = $r[1];
576
-		$ancre = $r[2];
577
-	} else {
578
-		$ancre = '';
579
-	}
580
-
581
-	// eclater
582
-	$url = preg_split(',[?]|&amp;|&,', $url);
583
-
584
-	// recuperer la base
585
-	$a = array_shift($url);
586
-	if (!$a) {
587
-		$a = './';
588
-	}
589
-
590
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
591
-	$ajouts = array_flip(explode('|', $c));
592
-	$u = is_array($v) ? $v : rawurlencode($v);
593
-	$testv = (is_array($v) ? count($v) : strlen($v));
594
-	$v_read = null;
595
-	// lire les variables et agir
596
-	foreach ($url as $n => $val) {
597
-		if (preg_match($regexp, urldecode($val), $r)) {
598
-			$r = array_pad($r, 3, null);
599
-			if ($v === null) {
600
-				// c'est un tableau, on memorise les valeurs
601
-				if (substr($r[1], -2) == '[]') {
602
-					if (!$v_read) {
603
-						$v_read = [];
604
-					}
605
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
606
-				} // c'est un scalaire, on retourne direct
607
-				else {
608
-					return $r[2] ? substr($r[2], 1) : '';
609
-				}
610
-			} // suppression
611
-			elseif (!$testv) {
612
-				unset($url[$n]);
613
-			}
614
-			// Ajout. Pour une variable, remplacer au meme endroit,
615
-			// pour un tableau ce sera fait dans la prochaine boucle
616
-			elseif (substr($r[1], -2) != '[]') {
617
-				$url[$n] = $r[1] . '=' . $u;
618
-				unset($ajouts[$r[1]]);
619
-			}
620
-			// Pour les tableaux on laisse tomber les valeurs de
621
-			// départ, on remplira à l'étape suivante
622
-			else {
623
-				unset($url[$n]);
624
-			}
625
-		}
626
-	}
627
-
628
-	// traiter les parametres pas encore trouves
629
-	if (
630
-		$v === null
631
-		and $args = func_get_args()
632
-		and count($args) == 2
633
-	) {
634
-		return $v_read; // rien trouve ou un tableau
635
-	} elseif ($testv) {
636
-		foreach ($ajouts as $k => $n) {
637
-			if (!is_array($v)) {
638
-				$url[] = $k . '=' . $u;
639
-			} else {
640
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
641
-				foreach ($v as $w) {
642
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
643
-				}
644
-			}
645
-		}
646
-	}
647
-
648
-	// eliminer les vides
649
-	$url = array_filter($url);
650
-
651
-	// recomposer l'adresse
652
-	if ($url) {
653
-		$a .= '?' . join($sep, $url);
654
-	}
655
-
656
-	return $a . $ancre;
567
+    // requete erronnee : plusieurs variable dans $c et aucun $v
568
+    if (strpos($c, '|') !== false and is_null($v)) {
569
+        return null;
570
+    }
571
+
572
+    // lever l'#ancre
573
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
574
+        $url = $r[1];
575
+        $ancre = $r[2];
576
+    } else {
577
+        $ancre = '';
578
+    }
579
+
580
+    // eclater
581
+    $url = preg_split(',[?]|&amp;|&,', $url);
582
+
583
+    // recuperer la base
584
+    $a = array_shift($url);
585
+    if (!$a) {
586
+        $a = './';
587
+    }
588
+
589
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
590
+    $ajouts = array_flip(explode('|', $c));
591
+    $u = is_array($v) ? $v : rawurlencode($v);
592
+    $testv = (is_array($v) ? count($v) : strlen($v));
593
+    $v_read = null;
594
+    // lire les variables et agir
595
+    foreach ($url as $n => $val) {
596
+        if (preg_match($regexp, urldecode($val), $r)) {
597
+            $r = array_pad($r, 3, null);
598
+            if ($v === null) {
599
+                // c'est un tableau, on memorise les valeurs
600
+                if (substr($r[1], -2) == '[]') {
601
+                    if (!$v_read) {
602
+                        $v_read = [];
603
+                    }
604
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
605
+                } // c'est un scalaire, on retourne direct
606
+                else {
607
+                    return $r[2] ? substr($r[2], 1) : '';
608
+                }
609
+            } // suppression
610
+            elseif (!$testv) {
611
+                unset($url[$n]);
612
+            }
613
+            // Ajout. Pour une variable, remplacer au meme endroit,
614
+            // pour un tableau ce sera fait dans la prochaine boucle
615
+            elseif (substr($r[1], -2) != '[]') {
616
+                $url[$n] = $r[1] . '=' . $u;
617
+                unset($ajouts[$r[1]]);
618
+            }
619
+            // Pour les tableaux on laisse tomber les valeurs de
620
+            // départ, on remplira à l'étape suivante
621
+            else {
622
+                unset($url[$n]);
623
+            }
624
+        }
625
+    }
626
+
627
+    // traiter les parametres pas encore trouves
628
+    if (
629
+        $v === null
630
+        and $args = func_get_args()
631
+        and count($args) == 2
632
+    ) {
633
+        return $v_read; // rien trouve ou un tableau
634
+    } elseif ($testv) {
635
+        foreach ($ajouts as $k => $n) {
636
+            if (!is_array($v)) {
637
+                $url[] = $k . '=' . $u;
638
+            } else {
639
+                $id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
640
+                foreach ($v as $w) {
641
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
642
+                }
643
+            }
644
+        }
645
+    }
646
+
647
+    // eliminer les vides
648
+    $url = array_filter($url);
649
+
650
+    // recomposer l'adresse
651
+    if ($url) {
652
+        $a .= '?' . join($sep, $url);
653
+    }
654
+
655
+    return $a . $ancre;
657 656
 }
658 657
 
659 658
 /**
@@ -671,21 +670,21 @@  discard block
 block discarded – undo
671 670
  * @return string
672 671
  */
673 672
 function ancre_url($url, $ancre) {
674
-	// lever l'#ancre
675
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
676
-		$url = $r[1];
677
-	}
678
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
679
-		if (!function_exists('translitteration')) {
680
-			include_spip('inc/charsets');
681
-		}
682
-		$ancre = preg_replace(
683
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
684
-			['', '-'],
685
-			translitteration($ancre)
686
-		);
687
-	}
688
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
673
+    // lever l'#ancre
674
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
675
+        $url = $r[1];
676
+    }
677
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
678
+        if (!function_exists('translitteration')) {
679
+            include_spip('inc/charsets');
680
+        }
681
+        $ancre = preg_replace(
682
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
683
+            ['', '-'],
684
+            translitteration($ancre)
685
+        );
686
+    }
687
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
689 688
 }
690 689
 
691 690
 /**
@@ -695,16 +694,16 @@  discard block
 block discarded – undo
695 694
  * @return string
696 695
  */
697 696
 function nettoyer_uri($reset = null) {
698
-	static $done = false;
699
-	static $propre = '';
700
-	if (!is_null($reset)) {
701
-		return $propre = $reset;
702
-	}
703
-	if ($done) {
704
-		return $propre;
705
-	}
706
-	$done = true;
707
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
697
+    static $done = false;
698
+    static $propre = '';
699
+    if (!is_null($reset)) {
700
+        return $propre = $reset;
701
+    }
702
+    if ($done) {
703
+        return $propre;
704
+    }
705
+    $done = true;
706
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
708 707
 }
709 708
 
710 709
 /**
@@ -716,16 +715,16 @@  discard block
 block discarded – undo
716 715
  * @return string
717 716
  */
718 717
 function nettoyer_uri_var($request_uri) {
719
-	$uri1 = $request_uri;
720
-	do {
721
-		$uri = $uri1;
722
-		$uri1 = preg_replace(
723
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
724
-			'\1',
725
-			$uri
726
-		);
727
-	} while ($uri <> $uri1);
728
-	return preg_replace(',[?&]$,', '', $uri1);
718
+    $uri1 = $request_uri;
719
+    do {
720
+        $uri = $uri1;
721
+        $uri1 = preg_replace(
722
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
723
+            '\1',
724
+            $uri
725
+        );
726
+    } while ($uri <> $uri1);
727
+    return preg_replace(',[?&]$,', '', $uri1);
729 728
 }
730 729
 
731 730
 
@@ -739,48 +738,48 @@  discard block
 block discarded – undo
739 738
  *    URL vers soi-même
740 739
  **/
741 740
 function self($amp = '&amp;', $root = false) {
742
-	$url = nettoyer_uri();
743
-	if (
744
-		!$root
745
-		and (
746
-			// si pas de profondeur on peut tronquer
747
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
748
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
749
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
750
-	) {
751
-		$url = preg_replace(',^[^?]*/,', '', $url);
752
-	}
753
-	// ajouter le cas echeant les variables _POST['id_...']
754
-	foreach ($_POST as $v => $c) {
755
-		if (substr($v, 0, 3) == 'id_') {
756
-			$url = parametre_url($url, $v, $c, '&');
757
-		}
758
-	}
759
-
760
-	// supprimer les variables sans interet
761
-	if (test_espace_prive()) {
762
-		$url = preg_replace(',([?&])('
763
-			. 'lang|show_docs|'
764
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
765
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
766
-		$url = preg_replace(',[&]$,', '\1', $url);
767
-	}
768
-
769
-	// eviter les hacks
770
-	include_spip('inc/filtres_mini');
771
-	$url = spip_htmlspecialchars($url);
772
-
773
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
774
-
775
-	// &amp; ?
776
-	if ($amp != '&amp;') {
777
-		$url = str_replace('&amp;', $amp, $url);
778
-	}
779
-
780
-	// Si ca demarre par ? ou vide, donner './'
781
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
782
-
783
-	return $url;
741
+    $url = nettoyer_uri();
742
+    if (
743
+        !$root
744
+        and (
745
+            // si pas de profondeur on peut tronquer
746
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
747
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
748
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
749
+    ) {
750
+        $url = preg_replace(',^[^?]*/,', '', $url);
751
+    }
752
+    // ajouter le cas echeant les variables _POST['id_...']
753
+    foreach ($_POST as $v => $c) {
754
+        if (substr($v, 0, 3) == 'id_') {
755
+            $url = parametre_url($url, $v, $c, '&');
756
+        }
757
+    }
758
+
759
+    // supprimer les variables sans interet
760
+    if (test_espace_prive()) {
761
+        $url = preg_replace(',([?&])('
762
+            . 'lang|show_docs|'
763
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
764
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
765
+        $url = preg_replace(',[&]$,', '\1', $url);
766
+    }
767
+
768
+    // eviter les hacks
769
+    include_spip('inc/filtres_mini');
770
+    $url = spip_htmlspecialchars($url);
771
+
772
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
773
+
774
+    // &amp; ?
775
+    if ($amp != '&amp;') {
776
+        $url = str_replace('&amp;', $amp, $url);
777
+    }
778
+
779
+    // Si ca demarre par ? ou vide, donner './'
780
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
781
+
782
+    return $url;
784 783
 }
785 784
 
786 785
 
@@ -791,7 +790,7 @@  discard block
 block discarded – undo
791 790
  *     true si c'est le cas, false sinon.
792 791
  */
793 792
 function test_espace_prive() {
794
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
793
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
795 794
 }
796 795
 
797 796
 /**
@@ -801,7 +800,7 @@  discard block
 block discarded – undo
801 800
  * @return bool
802 801
  */
803 802
 function test_plugin_actif($plugin) {
804
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
803
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
805 804
 }
806 805
 
807 806
 /**
@@ -832,53 +831,53 @@  discard block
 block discarded – undo
832 831
  *     Texte
833 832
  */
834 833
 function _T($texte, $args = [], $options = []) {
835
-	static $traduire = false;
836
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
837
-	if ($options) {
838
-		// support de l'ancien argument $class
839
-		if (is_string($options)) {
840
-			$options = ['class' => $options];
841
-		}
842
-		$o = array_merge($o, $options);
843
-	}
844
-
845
-	if (!$traduire) {
846
-		$traduire = charger_fonction('traduire', 'inc');
847
-		include_spip('inc/lang');
848
-	}
849
-
850
-	// On peut passer explicitement la langue dans le tableau
851
-	// On utilise le même nom de variable que la globale
852
-	if (isset($args['spip_lang'])) {
853
-		$lang = $args['spip_lang'];
854
-		// On l'enleve pour ne pas le passer au remplacement
855
-		unset($args['spip_lang']);
856
-	} // Sinon on prend la langue du contexte
857
-	else {
858
-		$lang = $GLOBALS['spip_lang'];
859
-	}
860
-	$text = $traduire($texte, $lang);
861
-
862
-	if (!strlen($text)) {
863
-		if (!$o['force']) {
864
-			return '';
865
-		}
866
-
867
-		$text = $texte;
868
-
869
-		// pour les chaines non traduites, assurer un service minimum
870
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
871
-			$text = str_replace(
872
-				'_',
873
-				' ',
874
-				(($n = strpos($text, ':')) === false ? $texte :
875
-				substr($texte, $n + 1))
876
-			);
877
-		}
878
-		$o['class'] = null;
879
-	}
880
-
881
-	return _L($text, $args, $o);
834
+    static $traduire = false;
835
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
836
+    if ($options) {
837
+        // support de l'ancien argument $class
838
+        if (is_string($options)) {
839
+            $options = ['class' => $options];
840
+        }
841
+        $o = array_merge($o, $options);
842
+    }
843
+
844
+    if (!$traduire) {
845
+        $traduire = charger_fonction('traduire', 'inc');
846
+        include_spip('inc/lang');
847
+    }
848
+
849
+    // On peut passer explicitement la langue dans le tableau
850
+    // On utilise le même nom de variable que la globale
851
+    if (isset($args['spip_lang'])) {
852
+        $lang = $args['spip_lang'];
853
+        // On l'enleve pour ne pas le passer au remplacement
854
+        unset($args['spip_lang']);
855
+    } // Sinon on prend la langue du contexte
856
+    else {
857
+        $lang = $GLOBALS['spip_lang'];
858
+    }
859
+    $text = $traduire($texte, $lang);
860
+
861
+    if (!strlen($text)) {
862
+        if (!$o['force']) {
863
+            return '';
864
+        }
865
+
866
+        $text = $texte;
867
+
868
+        // pour les chaines non traduites, assurer un service minimum
869
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
870
+            $text = str_replace(
871
+                '_',
872
+                ' ',
873
+                (($n = strpos($text, ':')) === false ? $texte :
874
+                substr($texte, $n + 1))
875
+            );
876
+        }
877
+        $o['class'] = null;
878
+    }
879
+
880
+    return _L($text, $args, $o);
882 881
 }
883 882
 
884 883
 
@@ -905,53 +904,53 @@  discard block
 block discarded – undo
905 904
  *     Texte
906 905
  */
907 906
 function _L($text, $args = [], $options = []) {
908
-	$f = $text;
909
-	$defaut_options = [
910
-		'class' => null,
911
-		'sanitize' => true,
912
-	];
913
-	// support de l'ancien argument $class
914
-	if ($options and is_string($options)) {
915
-		$options = ['class' => $options];
916
-	}
917
-	if (is_array($options)) {
918
-		$options += $defaut_options;
919
-	} else {
920
-		$options = $defaut_options;
921
-	}
922
-
923
-	if (is_array($args) and count($args)) {
924
-		if (!function_exists('interdire_scripts')) {
925
-			include_spip('inc/texte');
926
-		}
927
-		if (!function_exists('echapper_html_suspect')) {
928
-			include_spip('inc/texte_mini');
929
-		}
930
-		foreach ($args as $name => $value) {
931
-			if (strpos($text, "@$name@") !== false) {
932
-				if ($options['sanitize']) {
933
-					$value = echapper_html_suspect($value);
934
-					$value = interdire_scripts($value, -1);
935
-				}
936
-				if (!empty($options['class'])) {
937
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
938
-				}
939
-				$text = str_replace("@$name@", $value, $text);
940
-				unset($args[$name]);
941
-			}
942
-		}
943
-		// Si des variables n'ont pas ete inserees, le signaler
944
-		// (chaines de langues pas a jour)
945
-		if ($args) {
946
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
947
-		}
948
-	}
949
-
950
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
951
-		return "<span class='debug-traduction-erreur'>$text</span>";
952
-	} else {
953
-		return $text;
954
-	}
907
+    $f = $text;
908
+    $defaut_options = [
909
+        'class' => null,
910
+        'sanitize' => true,
911
+    ];
912
+    // support de l'ancien argument $class
913
+    if ($options and is_string($options)) {
914
+        $options = ['class' => $options];
915
+    }
916
+    if (is_array($options)) {
917
+        $options += $defaut_options;
918
+    } else {
919
+        $options = $defaut_options;
920
+    }
921
+
922
+    if (is_array($args) and count($args)) {
923
+        if (!function_exists('interdire_scripts')) {
924
+            include_spip('inc/texte');
925
+        }
926
+        if (!function_exists('echapper_html_suspect')) {
927
+            include_spip('inc/texte_mini');
928
+        }
929
+        foreach ($args as $name => $value) {
930
+            if (strpos($text, "@$name@") !== false) {
931
+                if ($options['sanitize']) {
932
+                    $value = echapper_html_suspect($value);
933
+                    $value = interdire_scripts($value, -1);
934
+                }
935
+                if (!empty($options['class'])) {
936
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
937
+                }
938
+                $text = str_replace("@$name@", $value, $text);
939
+                unset($args[$name]);
940
+            }
941
+        }
942
+        // Si des variables n'ont pas ete inserees, le signaler
943
+        // (chaines de langues pas a jour)
944
+        if ($args) {
945
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
946
+        }
947
+    }
948
+
949
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
950
+        return "<span class='debug-traduction-erreur'>$text</span>";
951
+    } else {
952
+        return $text;
953
+    }
955 954
 }
956 955
 
957 956
 
@@ -965,13 +964,13 @@  discard block
 block discarded – undo
965 964
  * @return string
966 965
  */
967 966
 function joli_repertoire($rep) {
968
-	$a = substr($rep, 0, 1);
969
-	if ($a <> '.' and $a <> '/') {
970
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
971
-	}
972
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
967
+    $a = substr($rep, 0, 1);
968
+    if ($a <> '.' and $a <> '/') {
969
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
970
+    }
971
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
973 972
 
974
-	return $rep;
973
+    return $rep;
975 974
 }
976 975
 
977 976
 
@@ -996,33 +995,33 @@  discard block
 block discarded – undo
996 995
  * @return float|int|string|void
997 996
  */
998 997
 function spip_timer($t = 'rien', $raw = false) {
999
-	static $time;
1000
-	$a = time();
1001
-	$b = microtime();
1002
-	// microtime peut contenir les microsecondes et le temps
1003
-	$b = explode(' ', $b);
1004
-	if (count($b) == 2) {
1005
-		$a = end($b);
1006
-	} // plus precis !
1007
-	$b = reset($b);
1008
-	if (!isset($time[$t])) {
1009
-		$time[$t] = $a + $b;
1010
-	} else {
1011
-		$p = ($a + $b - $time[$t]) * 1000;
1012
-		unset($time[$t]);
998
+    static $time;
999
+    $a = time();
1000
+    $b = microtime();
1001
+    // microtime peut contenir les microsecondes et le temps
1002
+    $b = explode(' ', $b);
1003
+    if (count($b) == 2) {
1004
+        $a = end($b);
1005
+    } // plus precis !
1006
+    $b = reset($b);
1007
+    if (!isset($time[$t])) {
1008
+        $time[$t] = $a + $b;
1009
+    } else {
1010
+        $p = ($a + $b - $time[$t]) * 1000;
1011
+        unset($time[$t]);
1013 1012
 #			echo "'$p'";exit;
1014
-		if ($raw) {
1015
-			return $p;
1016
-		}
1017
-		if ($p < 1000) {
1018
-			$s = '';
1019
-		} else {
1020
-			$s = sprintf('%d ', $x = floor($p / 1000));
1021
-			$p -= ($x * 1000);
1022
-		}
1013
+        if ($raw) {
1014
+            return $p;
1015
+        }
1016
+        if ($p < 1000) {
1017
+            $s = '';
1018
+        } else {
1019
+            $s = sprintf('%d ', $x = floor($p / 1000));
1020
+            $p -= ($x * 1000);
1021
+        }
1023 1022
 
1024
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1025
-	}
1023
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1024
+    }
1026 1025
 }
1027 1026
 
1028 1027
 
@@ -1030,21 +1029,21 @@  discard block
 block discarded – undo
1030 1029
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1031 1030
 // https://code.spip.net/@spip_touch
1032 1031
 function spip_touch($fichier, $duree = 0, $touch = true) {
1033
-	if ($duree) {
1034
-		clearstatcache();
1035
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1036
-			return false;
1037
-		}
1038
-	}
1039
-	if ($touch !== false) {
1040
-		if (!@touch($fichier)) {
1041
-			spip_unlink($fichier);
1042
-			@touch($fichier);
1043
-		};
1044
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1045
-	}
1032
+    if ($duree) {
1033
+        clearstatcache();
1034
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1035
+            return false;
1036
+        }
1037
+    }
1038
+    if ($touch !== false) {
1039
+        if (!@touch($fichier)) {
1040
+            spip_unlink($fichier);
1041
+            @touch($fichier);
1042
+        };
1043
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1044
+    }
1046 1045
 
1047
-	return true;
1046
+    return true;
1048 1047
 }
1049 1048
 
1050 1049
 
@@ -1055,11 +1054,11 @@  discard block
 block discarded – undo
1055 1054
  * @uses cron()
1056 1055
  **/
1057 1056
 function action_cron() {
1058
-	include_spip('inc/headers');
1059
-	http_response_code(204); // No Content
1060
-	header('Connection: close');
1061
-	define('_DIRECT_CRON_FORCE', true);
1062
-	cron();
1057
+    include_spip('inc/headers');
1058
+    http_response_code(204); // No Content
1059
+    header('Connection: close');
1060
+    define('_DIRECT_CRON_FORCE', true);
1061
+    cron();
1063 1062
 }
1064 1063
 
1065 1064
 /**
@@ -1075,26 +1074,26 @@  discard block
 block discarded – undo
1075 1074
  *     True si la tache a pu être effectuée
1076 1075
  */
1077 1076
 function cron($taches = [], $taches_old = []) {
1078
-	// si pas en mode cron force, laisser tomber.
1079
-	if (!defined('_DIRECT_CRON_FORCE')) {
1080
-		return false;
1081
-	}
1082
-	if (!is_array($taches)) {
1083
-		$taches = $taches_old;
1084
-	} // compat anciens appels
1085
-	// si taches a inserer en base et base inaccessible, laisser tomber
1086
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1087
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1088
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1089
-	if ($taches and count($taches) and !spip_connect()) {
1090
-		return false;
1091
-	}
1092
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1093
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1094
-		return $genie($taches);
1095
-	}
1096
-
1097
-	return false;
1077
+    // si pas en mode cron force, laisser tomber.
1078
+    if (!defined('_DIRECT_CRON_FORCE')) {
1079
+        return false;
1080
+    }
1081
+    if (!is_array($taches)) {
1082
+        $taches = $taches_old;
1083
+    } // compat anciens appels
1084
+    // si taches a inserer en base et base inaccessible, laisser tomber
1085
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1086
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1087
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1088
+    if ($taches and count($taches) and !spip_connect()) {
1089
+        return false;
1090
+    }
1091
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1092
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1093
+        return $genie($taches);
1094
+    }
1095
+
1096
+    return false;
1098 1097
 }
1099 1098
 
1100 1099
 /**
@@ -1126,17 +1125,17 @@  discard block
 block discarded – undo
1126 1125
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1127 1126
  */
1128 1127
 function job_queue_add(
1129
-	$function,
1130
-	$description,
1131
-	$arguments = [],
1132
-	$file = '',
1133
-	$no_duplicate = false,
1134
-	$time = 0,
1135
-	$priority = 0
1128
+    $function,
1129
+    $description,
1130
+    $arguments = [],
1131
+    $file = '',
1132
+    $no_duplicate = false,
1133
+    $time = 0,
1134
+    $priority = 0
1136 1135
 ) {
1137
-	include_spip('inc/queue');
1136
+    include_spip('inc/queue');
1138 1137
 
1139
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1138
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1140 1139
 }
1141 1140
 
1142 1141
 /**
@@ -1147,9 +1146,9 @@  discard block
 block discarded – undo
1147 1146
  * @return bool
1148 1147
  */
1149 1148
 function job_queue_remove($id_job) {
1150
-	include_spip('inc/queue');
1149
+    include_spip('inc/queue');
1151 1150
 
1152
-	return queue_remove_job($id_job);
1151
+    return queue_remove_job($id_job);
1153 1152
 }
1154 1153
 
1155 1154
 /**
@@ -1162,9 +1161,9 @@  discard block
 block discarded – undo
1162 1161
  *     or an array of simple array to link multiples objet in one time
1163 1162
  */
1164 1163
 function job_queue_link($id_job, $objets) {
1165
-	include_spip('inc/queue');
1164
+    include_spip('inc/queue');
1166 1165
 
1167
-	return queue_link_job($id_job, $objets);
1166
+    return queue_link_job($id_job, $objets);
1168 1167
 }
1169 1168
 
1170 1169
 
@@ -1184,36 +1183,36 @@  discard block
 block discarded – undo
1184 1183
  *  - `null` si la queue n'est pas encore initialisée
1185 1184
  */
1186 1185
 function queue_sleep_time_to_next_job($force = null) {
1187
-	static $queue_next_job_time = -1;
1188
-	if ($force === true) {
1189
-		$queue_next_job_time = -1;
1190
-	} elseif ($force) {
1191
-		$queue_next_job_time = $force;
1192
-	}
1193
-
1194
-	if ($queue_next_job_time == -1) {
1195
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1196
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1197
-		}
1198
-		// utiliser un cache memoire si dispo
1199
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1200
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1201
-		} else {
1202
-			$queue_next_job_time = null;
1203
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1204
-				$queue_next_job_time = intval($contenu);
1205
-			}
1206
-		}
1207
-	}
1208
-
1209
-	if (is_null($queue_next_job_time)) {
1210
-		return null;
1211
-	}
1212
-	if (!$_SERVER['REQUEST_TIME']) {
1213
-		$_SERVER['REQUEST_TIME'] = time();
1214
-	}
1215
-
1216
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1186
+    static $queue_next_job_time = -1;
1187
+    if ($force === true) {
1188
+        $queue_next_job_time = -1;
1189
+    } elseif ($force) {
1190
+        $queue_next_job_time = $force;
1191
+    }
1192
+
1193
+    if ($queue_next_job_time == -1) {
1194
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1195
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1196
+        }
1197
+        // utiliser un cache memoire si dispo
1198
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1199
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1200
+        } else {
1201
+            $queue_next_job_time = null;
1202
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1203
+                $queue_next_job_time = intval($contenu);
1204
+            }
1205
+        }
1206
+    }
1207
+
1208
+    if (is_null($queue_next_job_time)) {
1209
+        return null;
1210
+    }
1211
+    if (!$_SERVER['REQUEST_TIME']) {
1212
+        $_SERVER['REQUEST_TIME'] = time();
1213
+    }
1214
+
1215
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1217 1216
 }
1218 1217
 
1219 1218
 
@@ -1225,11 +1224,11 @@  discard block
 block discarded – undo
1225 1224
  * @return string
1226 1225
  */
1227 1226
 function quote_amp($u) {
1228
-	return preg_replace(
1229
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1230
-		'&amp;',
1231
-		$u
1232
-	);
1227
+    return preg_replace(
1228
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1229
+        '&amp;',
1230
+        $u
1231
+    );
1233 1232
 }
1234 1233
 
1235 1234
 
@@ -1252,27 +1251,27 @@  discard block
 block discarded – undo
1252 1251
  *     Balise HTML `<script>` et son contenu
1253 1252
  **/
1254 1253
 function http_script($script, $src = '', $noscript = '') {
1255
-	static $done = [];
1254
+    static $done = [];
1256 1255
 
1257
-	if ($src && !isset($done[$src])) {
1258
-		$done[$src] = true;
1259
-		$src = find_in_path($src, _JAVASCRIPT);
1260
-		$src = " src='$src'";
1261
-	} else {
1262
-		$src = '';
1263
-	}
1264
-	if ($script) {
1265
-		$script = ("/*<![CDATA[*/\n" .
1266
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1267
-			'/*]]>*/');
1268
-	}
1269
-	if ($noscript) {
1270
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1271
-	}
1256
+    if ($src && !isset($done[$src])) {
1257
+        $done[$src] = true;
1258
+        $src = find_in_path($src, _JAVASCRIPT);
1259
+        $src = " src='$src'";
1260
+    } else {
1261
+        $src = '';
1262
+    }
1263
+    if ($script) {
1264
+        $script = ("/*<![CDATA[*/\n" .
1265
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1266
+            '/*]]>*/');
1267
+    }
1268
+    if ($noscript) {
1269
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1270
+    }
1272 1271
 
1273
-	return ($src or $script or $noscript)
1274
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1275
-		: '';
1272
+    return ($src or $script or $noscript)
1273
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1274
+        : '';
1276 1275
 }
1277 1276
 
1278 1277
 
@@ -1307,7 +1306,7 @@  discard block
 block discarded – undo
1307 1306
  *     Texte échappé
1308 1307
  **/
1309 1308
 function texte_script($texte) {
1310
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1309
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1311 1310
 }
1312 1311
 
1313 1312
 
@@ -1344,68 +1343,68 @@  discard block
 block discarded – undo
1344 1343
  *     Liste des chemins, par ordre de priorité.
1345 1344
  **/
1346 1345
 function _chemin($dir_path = null) {
1347
-	static $path_base = null;
1348
-	static $path_full = null;
1349
-	if ($path_base == null) {
1350
-		// Chemin standard depuis l'espace public
1351
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1352
-			_DIR_RACINE . ':' .
1353
-			_DIR_RACINE . 'squelettes-dist/:' .
1354
-			_DIR_RACINE . 'prive/:' .
1355
-			_DIR_RESTREINT;
1356
-		// Ajouter squelettes/
1357
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1358
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1359
-		}
1360
-		foreach (explode(':', $path) as $dir) {
1361
-			if (strlen($dir) and substr($dir, -1) != '/') {
1362
-				$dir .= '/';
1363
-			}
1364
-			$path_base[] = $dir;
1365
-		}
1366
-		$path_full = $path_base;
1367
-		// Et le(s) dossier(s) des squelettes nommes
1368
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1369
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1370
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1371
-			}
1372
-		}
1373
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1374
-	}
1375
-	if ($dir_path === null) {
1376
-		return $path_full;
1377
-	}
1378
-
1379
-	if (is_array($dir_path) or strlen($dir_path)) {
1380
-		$tete = '';
1381
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1382
-			$tete = array_shift($path_base);
1383
-		}
1384
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1385
-		$dirs = array_reverse($dirs);
1386
-		foreach ($dirs as $dir_path) {
1387
-			if (substr($dir_path, -1) != '/') {
1388
-				$dir_path .= '/';
1389
-			}
1390
-			if (!in_array($dir_path, $path_base)) {
1391
-				array_unshift($path_base, $dir_path);
1392
-			}
1393
-		}
1394
-		if (strlen($tete)) {
1395
-			array_unshift($path_base, $tete);
1396
-		}
1397
-	}
1398
-	$path_full = $path_base;
1399
-	// Et le(s) dossier(s) des squelettes nommes
1400
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1401
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1402
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1403
-		}
1404
-	}
1405
-
1406
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1407
-
1408
-	return $path_full;
1346
+    static $path_base = null;
1347
+    static $path_full = null;
1348
+    if ($path_base == null) {
1349
+        // Chemin standard depuis l'espace public
1350
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1351
+            _DIR_RACINE . ':' .
1352
+            _DIR_RACINE . 'squelettes-dist/:' .
1353
+            _DIR_RACINE . 'prive/:' .
1354
+            _DIR_RESTREINT;
1355
+        // Ajouter squelettes/
1356
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1357
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1358
+        }
1359
+        foreach (explode(':', $path) as $dir) {
1360
+            if (strlen($dir) and substr($dir, -1) != '/') {
1361
+                $dir .= '/';
1362
+            }
1363
+            $path_base[] = $dir;
1364
+        }
1365
+        $path_full = $path_base;
1366
+        // Et le(s) dossier(s) des squelettes nommes
1367
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1368
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1369
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1370
+            }
1371
+        }
1372
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1373
+    }
1374
+    if ($dir_path === null) {
1375
+        return $path_full;
1376
+    }
1377
+
1378
+    if (is_array($dir_path) or strlen($dir_path)) {
1379
+        $tete = '';
1380
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1381
+            $tete = array_shift($path_base);
1382
+        }
1383
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1384
+        $dirs = array_reverse($dirs);
1385
+        foreach ($dirs as $dir_path) {
1386
+            if (substr($dir_path, -1) != '/') {
1387
+                $dir_path .= '/';
1388
+            }
1389
+            if (!in_array($dir_path, $path_base)) {
1390
+                array_unshift($path_base, $dir_path);
1391
+            }
1392
+        }
1393
+        if (strlen($tete)) {
1394
+            array_unshift($path_base, $tete);
1395
+        }
1396
+    }
1397
+    $path_full = $path_base;
1398
+    // Et le(s) dossier(s) des squelettes nommes
1399
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1400
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1401
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1402
+        }
1403
+    }
1404
+
1405
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1406
+
1407
+    return $path_full;
1409 1408
 }
1410 1409
 
1411 1410
 /**
@@ -1418,78 +1417,78 @@  discard block
 block discarded – undo
1418 1417
  * @return array Liste de chemins
1419 1418
  **/
1420 1419
 function creer_chemin() {
1421
-	$path_a = _chemin();
1422
-	static $c = '';
1420
+    $path_a = _chemin();
1421
+    static $c = '';
1423 1422
 
1424
-	// on calcule le chemin si le dossier skel a change
1425
-	if ($c != $GLOBALS['dossier_squelettes']) {
1426
-		// assurer le non plantage lors de la montee de version :
1427
-		$c = $GLOBALS['dossier_squelettes'];
1428
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1429
-	}
1423
+    // on calcule le chemin si le dossier skel a change
1424
+    if ($c != $GLOBALS['dossier_squelettes']) {
1425
+        // assurer le non plantage lors de la montee de version :
1426
+        $c = $GLOBALS['dossier_squelettes'];
1427
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1428
+    }
1430 1429
 
1431
-	return $path_a;
1430
+    return $path_a;
1432 1431
 }
1433 1432
 
1434 1433
 
1435 1434
 function lister_themes_prives() {
1436
-	static $themes = null;
1437
-	if (is_null($themes)) {
1438
-		// si pas encore definie
1439
-		if (!defined('_SPIP_THEME_PRIVE')) {
1440
-			define('_SPIP_THEME_PRIVE', 'spip');
1441
-		}
1442
-		$themes = [_SPIP_THEME_PRIVE];
1443
-		// lors d'une installation neuve, prefs n'est pas definie.
1444
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1445
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1446
-		} else {
1447
-			$prefs = [];
1448
-		}
1449
-		if (is_string($prefs)) {
1450
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1451
-		}
1452
-		if (
1453
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1454
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1455
-			and $theme != _SPIP_THEME_PRIVE
1456
-		) {
1457
-			array_unshift($themes, $theme);
1458
-		} // placer le theme choisi en tete
1459
-	}
1460
-
1461
-	return $themes;
1435
+    static $themes = null;
1436
+    if (is_null($themes)) {
1437
+        // si pas encore definie
1438
+        if (!defined('_SPIP_THEME_PRIVE')) {
1439
+            define('_SPIP_THEME_PRIVE', 'spip');
1440
+        }
1441
+        $themes = [_SPIP_THEME_PRIVE];
1442
+        // lors d'une installation neuve, prefs n'est pas definie.
1443
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1444
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1445
+        } else {
1446
+            $prefs = [];
1447
+        }
1448
+        if (is_string($prefs)) {
1449
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1450
+        }
1451
+        if (
1452
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1453
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1454
+            and $theme != _SPIP_THEME_PRIVE
1455
+        ) {
1456
+            array_unshift($themes, $theme);
1457
+        } // placer le theme choisi en tete
1458
+    }
1459
+
1460
+    return $themes;
1462 1461
 }
1463 1462
 
1464 1463
 function find_in_theme($file, $subdir = '', $include = false) {
1465
-	static $themefiles = [];
1466
-	if (isset($themefiles["$subdir$file"])) {
1467
-		return $themefiles["$subdir$file"];
1468
-	}
1469
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1470
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1471
-	if (
1472
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1473
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1474
-		and $f = find_in_theme("$file_svg_generique")
1475
-	) {
1476
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1477
-			return $themefiles["$subdir$file"] = $fsize;
1478
-		}
1479
-		else {
1480
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1481
-		}
1482
-	}
1483
-
1484
-	$themes = lister_themes_prives();
1485
-	foreach ($themes as $theme) {
1486
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1487
-			return $themefiles["$subdir$file"] = $f;
1488
-		}
1489
-	}
1490
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1491
-
1492
-	return $themefiles["$subdir$file"] = '';
1464
+    static $themefiles = [];
1465
+    if (isset($themefiles["$subdir$file"])) {
1466
+        return $themefiles["$subdir$file"];
1467
+    }
1468
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1469
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1470
+    if (
1471
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1472
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1473
+        and $f = find_in_theme("$file_svg_generique")
1474
+    ) {
1475
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1476
+            return $themefiles["$subdir$file"] = $fsize;
1477
+        }
1478
+        else {
1479
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1480
+        }
1481
+    }
1482
+
1483
+    $themes = lister_themes_prives();
1484
+    foreach ($themes as $theme) {
1485
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1486
+            return $themefiles["$subdir$file"] = $f;
1487
+        }
1488
+    }
1489
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1490
+
1491
+    return $themefiles["$subdir$file"] = '';
1493 1492
 }
1494 1493
 
1495 1494
 
@@ -1513,31 +1512,31 @@  discard block
 block discarded – undo
1513 1512
  *     sinon chaîne vide.
1514 1513
  **/
1515 1514
 function chemin_image($icone) {
1516
-	static $icone_renommer;
1517
-	if ($p = strpos($icone, '?')) {
1518
-		$icone = substr($icone, 0, $p);
1519
-	}
1520
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1521
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1522
-		return $icone;
1523
-	}
1524
-
1525
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1526
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1527
-		return $f;
1528
-	}
1529
-	// sinon passer par le module de renommage
1530
-	if (is_null($icone_renommer)) {
1531
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1532
-	}
1533
-	if ($icone_renommer) {
1534
-		list($icone, $fonction) = $icone_renommer($icone, '');
1535
-		if (file_exists($icone)) {
1536
-			return $icone;
1537
-		}
1538
-	}
1539
-
1540
-	return find_in_path($icone, _NOM_IMG_PACK);
1515
+    static $icone_renommer;
1516
+    if ($p = strpos($icone, '?')) {
1517
+        $icone = substr($icone, 0, $p);
1518
+    }
1519
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1520
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1521
+        return $icone;
1522
+    }
1523
+
1524
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1525
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1526
+        return $f;
1527
+    }
1528
+    // sinon passer par le module de renommage
1529
+    if (is_null($icone_renommer)) {
1530
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1531
+    }
1532
+    if ($icone_renommer) {
1533
+        list($icone, $fonction) = $icone_renommer($icone, '');
1534
+        if (file_exists($icone)) {
1535
+            return $icone;
1536
+        }
1537
+    }
1538
+
1539
+    return find_in_path($icone, _NOM_IMG_PACK);
1541 1540
 }
1542 1541
 
1543 1542
 //
@@ -1575,128 +1574,128 @@  discard block
 block discarded – undo
1575 1574
  *     - false : fichier introuvable
1576 1575
  **/
1577 1576
 function find_in_path($file, $dirname = '', $include = false) {
1578
-	static $dirs = [];
1579
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1580
-	static $c = '';
1581
-
1582
-	if (!$file and !strlen($file)) {
1583
-		return false;
1584
-	}
1585
-
1586
-	// on calcule le chemin si le dossier skel a change
1587
-	if ($c != $GLOBALS['dossier_squelettes']) {
1588
-		// assurer le non plantage lors de la montee de version :
1589
-		$c = $GLOBALS['dossier_squelettes'];
1590
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1591
-	}
1592
-
1593
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1594
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1595
-			return false;
1596
-		}
1597
-		if ($include and !isset($inc[$dirname][$file])) {
1598
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1599
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1600
-		}
1601
-
1602
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1603
-	}
1604
-
1605
-	$a = strrpos($file, '/');
1606
-	if ($a !== false) {
1607
-		$dirname .= substr($file, 0, ++$a);
1608
-		$file = substr($file, $a);
1609
-	}
1610
-
1611
-	foreach (creer_chemin() as $dir) {
1612
-		if (!isset($dirs[$a = $dir . $dirname])) {
1613
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1614
-		}
1615
-		if ($dirs[$a]) {
1616
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1617
-				if ($include and !isset($inc[$dirname][$file])) {
1618
-					include_once _ROOT_CWD . $a;
1619
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1620
-				}
1621
-				if (!defined('_SAUVER_CHEMIN')) {
1622
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1623
-					if (is_null($GLOBALS['path_files'])) {
1624
-						return $a;
1625
-					}
1626
-					define('_SAUVER_CHEMIN', true);
1627
-				}
1628
-
1629
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1630
-			}
1631
-		}
1632
-	}
1633
-
1634
-	if ($include) {
1635
-		spip_log("include_spip $dirname$file non trouve");
1636
-		if ($include === 'required') {
1637
-			echo '<pre>',
1638
-			'<strong>Erreur Fatale</strong><br />';
1639
-			if (function_exists('debug_print_backtrace')) {
1640
-				echo debug_print_backtrace();
1641
-			}
1642
-			echo '</pre>';
1643
-			die("Erreur interne: ne peut inclure $dirname$file");
1644
-		}
1645
-	}
1646
-
1647
-	if (!defined('_SAUVER_CHEMIN')) {
1648
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1649
-		if (is_null($GLOBALS['path_files'])) {
1650
-			return false;
1651
-		}
1652
-		define('_SAUVER_CHEMIN', true);
1653
-	}
1654
-
1655
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1577
+    static $dirs = [];
1578
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1579
+    static $c = '';
1580
+
1581
+    if (!$file and !strlen($file)) {
1582
+        return false;
1583
+    }
1584
+
1585
+    // on calcule le chemin si le dossier skel a change
1586
+    if ($c != $GLOBALS['dossier_squelettes']) {
1587
+        // assurer le non plantage lors de la montee de version :
1588
+        $c = $GLOBALS['dossier_squelettes'];
1589
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1590
+    }
1591
+
1592
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1593
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1594
+            return false;
1595
+        }
1596
+        if ($include and !isset($inc[$dirname][$file])) {
1597
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1598
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1599
+        }
1600
+
1601
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1602
+    }
1603
+
1604
+    $a = strrpos($file, '/');
1605
+    if ($a !== false) {
1606
+        $dirname .= substr($file, 0, ++$a);
1607
+        $file = substr($file, $a);
1608
+    }
1609
+
1610
+    foreach (creer_chemin() as $dir) {
1611
+        if (!isset($dirs[$a = $dir . $dirname])) {
1612
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1613
+        }
1614
+        if ($dirs[$a]) {
1615
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1616
+                if ($include and !isset($inc[$dirname][$file])) {
1617
+                    include_once _ROOT_CWD . $a;
1618
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1619
+                }
1620
+                if (!defined('_SAUVER_CHEMIN')) {
1621
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1622
+                    if (is_null($GLOBALS['path_files'])) {
1623
+                        return $a;
1624
+                    }
1625
+                    define('_SAUVER_CHEMIN', true);
1626
+                }
1627
+
1628
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1629
+            }
1630
+        }
1631
+    }
1632
+
1633
+    if ($include) {
1634
+        spip_log("include_spip $dirname$file non trouve");
1635
+        if ($include === 'required') {
1636
+            echo '<pre>',
1637
+            '<strong>Erreur Fatale</strong><br />';
1638
+            if (function_exists('debug_print_backtrace')) {
1639
+                echo debug_print_backtrace();
1640
+            }
1641
+            echo '</pre>';
1642
+            die("Erreur interne: ne peut inclure $dirname$file");
1643
+        }
1644
+    }
1645
+
1646
+    if (!defined('_SAUVER_CHEMIN')) {
1647
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1648
+        if (is_null($GLOBALS['path_files'])) {
1649
+            return false;
1650
+        }
1651
+        define('_SAUVER_CHEMIN', true);
1652
+    }
1653
+
1654
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1656 1655
 }
1657 1656
 
1658 1657
 function clear_path_cache() {
1659
-	$GLOBALS['path_files'] = [];
1660
-	spip_unlink(_CACHE_CHEMIN);
1658
+    $GLOBALS['path_files'] = [];
1659
+    spip_unlink(_CACHE_CHEMIN);
1661 1660
 }
1662 1661
 
1663 1662
 function load_path_cache() {
1664
-	// charger le path des plugins
1665
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1666
-		include_once(_CACHE_PLUGINS_PATH);
1667
-	}
1668
-	$GLOBALS['path_files'] = [];
1669
-	// si le visiteur est admin,
1670
-	// on ne recharge pas le cache pour forcer sa mise a jour
1671
-	if (
1672
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1673
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1674
-		// utiliser le cookie est un pis aller qui marche 'en general'
1675
-		// on blinde par un second test au moment de la lecture de la session
1676
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1677
-		// et en ignorant ce cache en cas de recalcul explicite
1678
-		!_request('var_mode')
1679
-	) {
1680
-		// on essaye de lire directement sans verrou pour aller plus vite
1681
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1682
-			// mais si semble corrompu on relit avec un verrou
1683
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1684
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1685
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1686
-					$GLOBALS['path_files'] = [];
1687
-				}
1688
-			}
1689
-		}
1690
-	}
1663
+    // charger le path des plugins
1664
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1665
+        include_once(_CACHE_PLUGINS_PATH);
1666
+    }
1667
+    $GLOBALS['path_files'] = [];
1668
+    // si le visiteur est admin,
1669
+    // on ne recharge pas le cache pour forcer sa mise a jour
1670
+    if (
1671
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1672
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1673
+        // utiliser le cookie est un pis aller qui marche 'en general'
1674
+        // on blinde par un second test au moment de la lecture de la session
1675
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1676
+        // et en ignorant ce cache en cas de recalcul explicite
1677
+        !_request('var_mode')
1678
+    ) {
1679
+        // on essaye de lire directement sans verrou pour aller plus vite
1680
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1681
+            // mais si semble corrompu on relit avec un verrou
1682
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1683
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1684
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1685
+                    $GLOBALS['path_files'] = [];
1686
+                }
1687
+            }
1688
+        }
1689
+    }
1691 1690
 }
1692 1691
 
1693 1692
 function save_path_cache() {
1694
-	if (
1695
-		defined('_SAUVER_CHEMIN')
1696
-		and _SAUVER_CHEMIN
1697
-	) {
1698
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1699
-	}
1693
+    if (
1694
+        defined('_SAUVER_CHEMIN')
1695
+        and _SAUVER_CHEMIN
1696
+    ) {
1697
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1698
+    }
1700 1699
 }
1701 1700
 
1702 1701
 
@@ -1716,33 +1715,33 @@  discard block
 block discarded – undo
1716 1715
  * @return array
1717 1716
  */
1718 1717
 function find_all_in_path($dir, $pattern, $recurs = false) {
1719
-	$liste_fichiers = [];
1720
-	$maxfiles = 10000;
1721
-
1722
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1723
-	// on a pas encore inclus flock.php
1724
-	if (!function_exists('preg_files')) {
1725
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1726
-	}
1727
-
1728
-	// Parcourir le chemin
1729
-	foreach (creer_chemin() as $d) {
1730
-		$f = $d . $dir;
1731
-		if (@is_dir($f)) {
1732
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1733
-			foreach ($liste as $chemin) {
1734
-				$nom = basename($chemin);
1735
-				// ne prendre que les fichiers pas deja trouves
1736
-				// car find_in_path prend le premier qu'il trouve,
1737
-				// les autres sont donc masques
1738
-				if (!isset($liste_fichiers[$nom])) {
1739
-					$liste_fichiers[$nom] = $chemin;
1740
-				}
1741
-			}
1742
-		}
1743
-	}
1744
-
1745
-	return $liste_fichiers;
1718
+    $liste_fichiers = [];
1719
+    $maxfiles = 10000;
1720
+
1721
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1722
+    // on a pas encore inclus flock.php
1723
+    if (!function_exists('preg_files')) {
1724
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1725
+    }
1726
+
1727
+    // Parcourir le chemin
1728
+    foreach (creer_chemin() as $d) {
1729
+        $f = $d . $dir;
1730
+        if (@is_dir($f)) {
1731
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1732
+            foreach ($liste as $chemin) {
1733
+                $nom = basename($chemin);
1734
+                // ne prendre que les fichiers pas deja trouves
1735
+                // car find_in_path prend le premier qu'il trouve,
1736
+                // les autres sont donc masques
1737
+                if (!isset($liste_fichiers[$nom])) {
1738
+                    $liste_fichiers[$nom] = $chemin;
1739
+                }
1740
+            }
1741
+        }
1742
+    }
1743
+
1744
+    return $liste_fichiers;
1746 1745
 }
1747 1746
 
1748 1747
 /**
@@ -1754,17 +1753,17 @@  discard block
 block discarded – undo
1754 1753
  * @return bool
1755 1754
  */
1756 1755
 function autoriser_sans_cookie($nom, $strict = false) {
1757
-	static $autsanscookie = ['install', 'base_repair'];
1756
+    static $autsanscookie = ['install', 'base_repair'];
1758 1757
 
1759
-	if (in_array($nom, $autsanscookie)) {
1760
-		if (test_espace_prive()) {
1761
-			include_spip('base/connect_sql');
1762
-			if (!$strict or !spip_connect()) {
1763
-				return true;
1764
-			}
1765
-		}
1766
-	}
1767
-	return false;
1758
+    if (in_array($nom, $autsanscookie)) {
1759
+        if (test_espace_prive()) {
1760
+            include_spip('base/connect_sql');
1761
+            if (!$strict or !spip_connect()) {
1762
+                return true;
1763
+            }
1764
+        }
1765
+    }
1766
+    return false;
1768 1767
 }
1769 1768
 
1770 1769
 /**
@@ -1790,99 +1789,99 @@  discard block
 block discarded – undo
1790 1789
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1791 1790
  */
1792 1791
 function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1793
-	if ($public === null) {
1794
-		$public = !test_espace_prive();
1795
-	}
1796
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1797
-
1798
-	if (!$public) {
1799
-		if (!$entite) {
1800
-			return '';
1801
-		}
1802
-		if (!function_exists('generer_url_ecrire_objet')) {
1803
-			include_spip('inc/urls');
1804
-		}
1805
-		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1806
-	} else {
1807
-		if ($type === null) {
1808
-			$type = (isset($GLOBALS['type_urls']))
1809
-				? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1810
-				: ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1811
-					? ($GLOBALS['meta']['type_urls']) : 'page'); // sinon type "page" par défaut
1812
-		}
1813
-
1814
-		$f = charger_fonction($type, 'urls', true);
1815
-		// se rabattre sur les urls page si les urls perso non dispo
1816
-		if (!$f) {
1817
-			$f = charger_fonction('page', 'urls', true);
1818
-		}
1819
-
1820
-		// si $entite='', on veut la fonction de passage URL ==> id
1821
-		// sinon on veut effectuer le passage id ==> URL
1822
-		if (!$entite) {
1823
-			return $f;
1824
-		}
1825
-
1826
-		// mais d'abord il faut tester le cas des urls sur une
1827
-		// base distante
1828
-		if (
1829
-			is_string($public)
1830
-			and $g = charger_fonction('connect', 'urls', true)
1831
-		) {
1832
-			$f = $g;
1833
-		}
1834
-
1835
-		$res = $f(intval($id), $entite, $args, $ancre, $public);
1836
-	}
1837
-	if ($res) {
1838
-		return $res;
1839
-	}
1840
-	// Sinon c'est un raccourci ou compat SPIP < 2
1841
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1842
-		if (!function_exists($f .= '_dist')) {
1843
-			$f = '';
1844
-		}
1845
-	}
1846
-	if ($f) {
1847
-		$url = $f($id, $args, $ancre);
1848
-		if (strlen($args)) {
1849
-			$url .= strstr($url, '?')
1850
-				? '&amp;' . $args
1851
-				: '?' . $args;
1852
-		}
1853
-
1854
-		return $url;
1855
-	}
1856
-	// On a ete gentil mais la ....
1857
-	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1858
-
1859
-	return '';
1792
+    if ($public === null) {
1793
+        $public = !test_espace_prive();
1794
+    }
1795
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1796
+
1797
+    if (!$public) {
1798
+        if (!$entite) {
1799
+            return '';
1800
+        }
1801
+        if (!function_exists('generer_url_ecrire_objet')) {
1802
+            include_spip('inc/urls');
1803
+        }
1804
+        $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1805
+    } else {
1806
+        if ($type === null) {
1807
+            $type = (isset($GLOBALS['type_urls']))
1808
+                ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1809
+                : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1810
+                    ? ($GLOBALS['meta']['type_urls']) : 'page'); // sinon type "page" par défaut
1811
+        }
1812
+
1813
+        $f = charger_fonction($type, 'urls', true);
1814
+        // se rabattre sur les urls page si les urls perso non dispo
1815
+        if (!$f) {
1816
+            $f = charger_fonction('page', 'urls', true);
1817
+        }
1818
+
1819
+        // si $entite='', on veut la fonction de passage URL ==> id
1820
+        // sinon on veut effectuer le passage id ==> URL
1821
+        if (!$entite) {
1822
+            return $f;
1823
+        }
1824
+
1825
+        // mais d'abord il faut tester le cas des urls sur une
1826
+        // base distante
1827
+        if (
1828
+            is_string($public)
1829
+            and $g = charger_fonction('connect', 'urls', true)
1830
+        ) {
1831
+            $f = $g;
1832
+        }
1833
+
1834
+        $res = $f(intval($id), $entite, $args, $ancre, $public);
1835
+    }
1836
+    if ($res) {
1837
+        return $res;
1838
+    }
1839
+    // Sinon c'est un raccourci ou compat SPIP < 2
1840
+    if (!function_exists($f = 'generer_url_' . $entite)) {
1841
+        if (!function_exists($f .= '_dist')) {
1842
+            $f = '';
1843
+        }
1844
+    }
1845
+    if ($f) {
1846
+        $url = $f($id, $args, $ancre);
1847
+        if (strlen($args)) {
1848
+            $url .= strstr($url, '?')
1849
+                ? '&amp;' . $args
1850
+                : '?' . $args;
1851
+        }
1852
+
1853
+        return $url;
1854
+    }
1855
+    // On a ete gentil mais la ....
1856
+    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1857
+
1858
+    return '';
1860 1859
 }
1861 1860
 
1862 1861
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1863
-	$exec = objet_info($entite, 'url_edit');
1864
-	$url = generer_url_ecrire($exec, $args);
1865
-	if (intval($id)) {
1866
-		$url = parametre_url($url, id_table_objet($entite), $id);
1867
-	} else {
1868
-		$url = parametre_url($url, 'new', 'oui');
1869
-	}
1870
-	if ($ancre) {
1871
-		$url = ancre_url($url, $ancre);
1872
-	}
1862
+    $exec = objet_info($entite, 'url_edit');
1863
+    $url = generer_url_ecrire($exec, $args);
1864
+    if (intval($id)) {
1865
+        $url = parametre_url($url, id_table_objet($entite), $id);
1866
+    } else {
1867
+        $url = parametre_url($url, 'new', 'oui');
1868
+    }
1869
+    if ($ancre) {
1870
+        $url = ancre_url($url, $ancre);
1871
+    }
1873 1872
 
1874
-	return $url;
1873
+    return $url;
1875 1874
 }
1876 1875
 
1877 1876
 // https://code.spip.net/@urls_connect_dist
1878 1877
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1879
-	include_spip('base/connect_sql');
1880
-	$id_type = id_table_objet($entite, $public);
1878
+    include_spip('base/connect_sql');
1879
+    $id_type = id_table_objet($entite, $public);
1881 1880
 
1882
-	return _DIR_RACINE . get_spip_script('./')
1883
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1884
-	. (!$args ? '' : "&$args")
1885
-	. (!$ancre ? '' : "#$ancre");
1881
+    return _DIR_RACINE . get_spip_script('./')
1882
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1883
+    . (!$args ? '' : "&$args")
1884
+    . (!$ancre ? '' : "#$ancre");
1886 1885
 }
1887 1886
 
1888 1887
 
@@ -1893,32 +1892,32 @@  discard block
 block discarded – undo
1893 1892
  * @return string
1894 1893
  */
1895 1894
 function urlencode_1738($url) {
1896
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1897
-		$uri = '';
1898
-		for ($i = 0; $i < strlen($url); $i++) {
1899
-			if (ord($a = $url[$i]) > 127) {
1900
-				$a = rawurlencode($a);
1901
-			}
1902
-			$uri .= $a;
1903
-		}
1904
-		$url = $uri;
1905
-	}
1895
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1896
+        $uri = '';
1897
+        for ($i = 0; $i < strlen($url); $i++) {
1898
+            if (ord($a = $url[$i]) > 127) {
1899
+                $a = rawurlencode($a);
1900
+            }
1901
+            $uri .= $a;
1902
+        }
1903
+        $url = $uri;
1904
+    }
1906 1905
 
1907
-	return quote_amp($url);
1906
+    return quote_amp($url);
1908 1907
 }
1909 1908
 
1910 1909
 // https://code.spip.net/@generer_url_entite_absolue
1911 1910
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1912
-	if (!$connect) {
1913
-		$connect = true;
1914
-	}
1915
-	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1916
-	if (!preg_match(',^\w+:,', $h)) {
1917
-		include_spip('inc/filtres_mini');
1918
-		$h = url_absolue($h);
1919
-	}
1911
+    if (!$connect) {
1912
+        $connect = true;
1913
+    }
1914
+    $h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1915
+    if (!preg_match(',^\w+:,', $h)) {
1916
+        include_spip('inc/filtres_mini');
1917
+        $h = url_absolue($h);
1918
+    }
1920 1919
 
1921
-	return $h;
1920
+    return $h;
1922 1921
 }
1923 1922
 
1924 1923
 
@@ -1934,11 +1933,11 @@  discard block
 block discarded – undo
1934 1933
  *     true si la valeur est considérée active ; false sinon.
1935 1934
  **/
1936 1935
 function test_valeur_serveur($truc) {
1937
-	if (!$truc) {
1938
-		return false;
1939
-	}
1936
+    if (!$truc) {
1937
+        return false;
1938
+    }
1940 1939
 
1941
-	return (strtolower($truc) !== 'off');
1940
+    return (strtolower($truc) !== 'off');
1942 1941
 }
1943 1942
 
1944 1943
 //
@@ -1966,82 +1965,82 @@  discard block
 block discarded – undo
1966 1965
  */
1967 1966
 function url_de_base($profondeur = null) {
1968 1967
 
1969
-	static $url = [];
1970
-	if (is_array($profondeur)) {
1971
-		return $url = $profondeur;
1972
-	}
1973
-	if ($profondeur === false) {
1974
-		return $url;
1975
-	}
1976
-
1977
-	if (is_null($profondeur)) {
1978
-		$profondeur = $GLOBALS['profondeur_url'];
1979
-	}
1980
-
1981
-	if (isset($url[$profondeur])) {
1982
-		return $url[$profondeur];
1983
-	}
1984
-
1985
-	$http = 'http';
1986
-
1987
-	if (
1988
-		isset($_SERVER['SCRIPT_URI'])
1989
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
1990
-	) {
1991
-		$http = 'https';
1992
-	} elseif (
1993
-		isset($_SERVER['HTTPS'])
1994
-		and test_valeur_serveur($_SERVER['HTTPS'])
1995
-	) {
1996
-		$http = 'https';
1997
-	}
1998
-
1999
-	// note : HTTP_HOST contient le :port si necessaire
2000
-	$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
2001
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2002
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2003
-		$host = $GLOBALS['meta']['adresse_site'];
2004
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2005
-			$http = $scheme;
2006
-			$host = str_replace("{$scheme}://", '', $host);
2007
-		}
2008
-	}
2009
-	if (
2010
-		isset($_SERVER['SERVER_PORT'])
2011
-		and $port = $_SERVER['SERVER_PORT']
2012
-		and strpos($host, ':') == false
2013
-	) {
2014
-		if (!defined('_PORT_HTTP_STANDARD')) {
2015
-			define('_PORT_HTTP_STANDARD', '80');
2016
-		}
2017
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2018
-			define('_PORT_HTTPS_STANDARD', '443');
2019
-		}
2020
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2021
-			$host .= ":$port";
2022
-		}
2023
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2024
-			$host .= ":$port";
2025
-		}
2026
-	}
2027
-
2028
-	if (!$GLOBALS['REQUEST_URI']) {
2029
-		if (isset($_SERVER['REQUEST_URI'])) {
2030
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2031
-		} else {
2032
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2033
-			if (
2034
-				!empty($_SERVER['QUERY_STRING'])
2035
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2036
-			) {
2037
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2038
-			}
2039
-		}
2040
-	}
2041
-
2042
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2043
-
2044
-	return $url[$profondeur];
1968
+    static $url = [];
1969
+    if (is_array($profondeur)) {
1970
+        return $url = $profondeur;
1971
+    }
1972
+    if ($profondeur === false) {
1973
+        return $url;
1974
+    }
1975
+
1976
+    if (is_null($profondeur)) {
1977
+        $profondeur = $GLOBALS['profondeur_url'];
1978
+    }
1979
+
1980
+    if (isset($url[$profondeur])) {
1981
+        return $url[$profondeur];
1982
+    }
1983
+
1984
+    $http = 'http';
1985
+
1986
+    if (
1987
+        isset($_SERVER['SCRIPT_URI'])
1988
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
1989
+    ) {
1990
+        $http = 'https';
1991
+    } elseif (
1992
+        isset($_SERVER['HTTPS'])
1993
+        and test_valeur_serveur($_SERVER['HTTPS'])
1994
+    ) {
1995
+        $http = 'https';
1996
+    }
1997
+
1998
+    // note : HTTP_HOST contient le :port si necessaire
1999
+    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
2000
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2001
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2002
+        $host = $GLOBALS['meta']['adresse_site'];
2003
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2004
+            $http = $scheme;
2005
+            $host = str_replace("{$scheme}://", '', $host);
2006
+        }
2007
+    }
2008
+    if (
2009
+        isset($_SERVER['SERVER_PORT'])
2010
+        and $port = $_SERVER['SERVER_PORT']
2011
+        and strpos($host, ':') == false
2012
+    ) {
2013
+        if (!defined('_PORT_HTTP_STANDARD')) {
2014
+            define('_PORT_HTTP_STANDARD', '80');
2015
+        }
2016
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2017
+            define('_PORT_HTTPS_STANDARD', '443');
2018
+        }
2019
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2020
+            $host .= ":$port";
2021
+        }
2022
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2023
+            $host .= ":$port";
2024
+        }
2025
+    }
2026
+
2027
+    if (!$GLOBALS['REQUEST_URI']) {
2028
+        if (isset($_SERVER['REQUEST_URI'])) {
2029
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2030
+        } else {
2031
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2032
+            if (
2033
+                !empty($_SERVER['QUERY_STRING'])
2034
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2035
+            ) {
2036
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2037
+            }
2038
+        }
2039
+    }
2040
+
2041
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2042
+
2043
+    return $url[$profondeur];
2045 2044
 }
2046 2045
 
2047 2046
 /**
@@ -2054,26 +2053,26 @@  discard block
 block discarded – undo
2054 2053
  * @return string
2055 2054
  */
2056 2055
 function url_de_($http, $host, $request, $prof = 0) {
2057
-	$prof = max($prof, 0);
2056
+    $prof = max($prof, 0);
2058 2057
 
2059
-	$myself = ltrim($request, '/');
2060
-	# supprimer la chaine de GET
2061
-	list($myself) = explode('?', $myself);
2062
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2063
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2064
-	if (strpos($myself, '://') !== false) {
2065
-		$myself = explode('://', $myself);
2066
-		array_shift($myself);
2067
-		$myself = implode('://', $myself);
2068
-		$myself = explode('/', $myself);
2069
-		array_shift($myself);
2070
-		$myself = implode('/', $myself);
2071
-	}
2072
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2058
+    $myself = ltrim($request, '/');
2059
+    # supprimer la chaine de GET
2060
+    list($myself) = explode('?', $myself);
2061
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2062
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2063
+    if (strpos($myself, '://') !== false) {
2064
+        $myself = explode('://', $myself);
2065
+        array_shift($myself);
2066
+        $myself = implode('://', $myself);
2067
+        $myself = explode('/', $myself);
2068
+        array_shift($myself);
2069
+        $myself = implode('/', $myself);
2070
+    }
2071
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2073 2072
 
2074
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2073
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2075 2074
 
2076
-	return $url;
2075
+    return $url;
2077 2076
 }
2078 2077
 
2079 2078
 
@@ -2108,26 +2107,26 @@  discard block
 block discarded – undo
2108 2107
  * @return string URL
2109 2108
  **/
2110 2109
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2111
-	if (!$rel) {
2112
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2113
-	} else {
2114
-		if (!is_string($rel)) {
2115
-			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2116
-				('./' . _SPIP_ECRIRE_SCRIPT);
2117
-		}
2118
-	}
2119
-
2120
-	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2121
-	if ($script and ($script <> 'accueil' or $rel)) {
2122
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2123
-	} elseif ($args) {
2124
-		$args = "?$args";
2125
-	}
2126
-	if ($ancre) {
2127
-		$args .= "#$ancre";
2128
-	}
2129
-
2130
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2110
+    if (!$rel) {
2111
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2112
+    } else {
2113
+        if (!is_string($rel)) {
2114
+            $rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2115
+                ('./' . _SPIP_ECRIRE_SCRIPT);
2116
+        }
2117
+    }
2118
+
2119
+    list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2120
+    if ($script and ($script <> 'accueil' or $rel)) {
2121
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2122
+    } elseif ($args) {
2123
+        $args = "?$args";
2124
+    }
2125
+    if ($ancre) {
2126
+        $args .= "#$ancre";
2127
+    }
2128
+
2129
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2131 2130
 }
2132 2131
 
2133 2132
 //
@@ -2149,12 +2148,12 @@  discard block
 block discarded – undo
2149 2148
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2150 2149
  **/
2151 2150
 function get_spip_script($default = '') {
2152
-	# cas define('_SPIP_SCRIPT', '');
2153
-	if (_SPIP_SCRIPT) {
2154
-		return _SPIP_SCRIPT;
2155
-	} else {
2156
-		return $default;
2157
-	}
2151
+    # cas define('_SPIP_SCRIPT', '');
2152
+    if (_SPIP_SCRIPT) {
2153
+        return _SPIP_SCRIPT;
2154
+    } else {
2155
+        return $default;
2156
+    }
2158 2157
 }
2159 2158
 
2160 2159
 /**
@@ -2183,39 +2182,39 @@  discard block
 block discarded – undo
2183 2182
  * @return string URL
2184 2183
  **/
2185 2184
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2186
-	// si le script est une action (spip_pass, spip_inscription),
2187
-	// standardiser vers la nouvelle API
2188
-
2189
-	if (!$action) {
2190
-		$action = get_spip_script();
2191
-	}
2192
-	if ($script) {
2193
-		$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2194
-	}
2195
-
2196
-	if ($args) {
2197
-		if (is_array($args)) {
2198
-			$r = '';
2199
-			foreach ($args as $k => $v) {
2200
-				$r .= '&' . $k . '=' . $v;
2201
-			}
2202
-			$args = substr($r, 1);
2203
-		}
2204
-		$action .=
2205
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2206
-	}
2207
-	if (!$no_entities) {
2208
-		$action = quote_amp($action);
2209
-	}
2210
-
2211
-	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2212
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2185
+    // si le script est une action (spip_pass, spip_inscription),
2186
+    // standardiser vers la nouvelle API
2187
+
2188
+    if (!$action) {
2189
+        $action = get_spip_script();
2190
+    }
2191
+    if ($script) {
2192
+        $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2193
+    }
2194
+
2195
+    if ($args) {
2196
+        if (is_array($args)) {
2197
+            $r = '';
2198
+            foreach ($args as $k => $v) {
2199
+                $r .= '&' . $k . '=' . $v;
2200
+            }
2201
+            $args = substr($r, 1);
2202
+        }
2203
+        $action .=
2204
+            (strpos($action, '?') !== false ? '&' : '?') . $args;
2205
+    }
2206
+    if (!$no_entities) {
2207
+        $action = quote_amp($action);
2208
+    }
2209
+
2210
+    // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2211
+    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2213 2212
 }
2214 2213
 
2215 2214
 // https://code.spip.net/@generer_url_prive
2216 2215
 function generer_url_prive($script, $args = '', $no_entities = false) {
2217 2216
 
2218
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2217
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2219 2218
 }
2220 2219
 
2221 2220
 // Pour les formulaires en methode POST,
@@ -2240,19 +2239,19 @@  discard block
 block discarded – undo
2240 2239
  **/
2241 2240
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2242 2241
 
2243
-	$script1 = explode('&', $script);
2244
-	$script1 = reset($script1);
2242
+    $script1 = explode('&', $script);
2243
+    $script1 = reset($script1);
2245 2244
 
2246
-	return "<form action='"
2247
-	. ($script ? generer_url_ecrire($script) : '')
2248
-	. "' "
2249
-	. ($atts ? $atts : " method='post'")
2250
-	. "><div>\n"
2251
-	. "<input type='hidden' name='exec' value='$script1' />"
2252
-	. $corps
2253
-	. (!$submit ? '' :
2254
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2255
-	. "</div></form>\n";
2245
+    return "<form action='"
2246
+    . ($script ? generer_url_ecrire($script) : '')
2247
+    . "' "
2248
+    . ($atts ? $atts : " method='post'")
2249
+    . "><div>\n"
2250
+    . "<input type='hidden' name='exec' value='$script1' />"
2251
+    . $corps
2252
+    . (!$submit ? '' :
2253
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2254
+    . "</div></form>\n";
2256 2255
 }
2257 2256
 
2258 2257
 /**
@@ -2269,22 +2268,22 @@  discard block
 block discarded – undo
2269 2268
  * @return string
2270 2269
  */
2271 2270
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2272
-	// si l'on est dans l'espace prive, on garde dans l'url
2273
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2274
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2275
-	$h = (_DIR_RACINE and !$public)
2276
-		? generer_url_ecrire(_request('exec'))
2277
-		: generer_url_public();
2271
+    // si l'on est dans l'espace prive, on garde dans l'url
2272
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2273
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2274
+    $h = (_DIR_RACINE and !$public)
2275
+        ? generer_url_ecrire(_request('exec'))
2276
+        : generer_url_public();
2278 2277
 
2279
-	return "\n<form action='" .
2280
-	$h .
2281
-	"'" .
2282
-	$atts .
2283
-	">\n" .
2284
-	'<div>' .
2285
-	"\n<input type='hidden' name='action' value='$script' />" .
2286
-	$corps .
2287
-	'</div></form>';
2278
+    return "\n<form action='" .
2279
+    $h .
2280
+    "'" .
2281
+    $atts .
2282
+    ">\n" .
2283
+    '<div>' .
2284
+    "\n<input type='hidden' name='action' value='$script' />" .
2285
+    $corps .
2286
+    '</div></form>';
2288 2287
 }
2289 2288
 
2290 2289
 /**
@@ -2303,22 +2302,22 @@  discard block
 block discarded – undo
2303 2302
  *     URL
2304 2303
  */
2305 2304
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2306
-	// si l'on est dans l'espace prive, on garde dans l'url
2307
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2308
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2309
-	$url = (_DIR_RACINE and !$public)
2310
-		? generer_url_ecrire(_request('exec'))
2311
-		: generer_url_public('', '', false, false);
2312
-	$url = parametre_url($url, 'action', $script);
2313
-	if ($args) {
2314
-		$url .= quote_amp('&' . $args);
2315
-	}
2305
+    // si l'on est dans l'espace prive, on garde dans l'url
2306
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2307
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2308
+    $url = (_DIR_RACINE and !$public)
2309
+        ? generer_url_ecrire(_request('exec'))
2310
+        : generer_url_public('', '', false, false);
2311
+    $url = parametre_url($url, 'action', $script);
2312
+    if ($args) {
2313
+        $url .= quote_amp('&' . $args);
2314
+    }
2316 2315
 
2317
-	if ($no_entities) {
2318
-		$url = str_replace('&amp;', '&', $url);
2319
-	}
2316
+    if ($no_entities) {
2317
+        $url = str_replace('&amp;', '&', $url);
2318
+    }
2320 2319
 
2321
-	return $url;
2320
+    return $url;
2322 2321
 }
2323 2322
 
2324 2323
 
@@ -2331,8 +2330,8 @@  discard block
 block discarded – undo
2331 2330
  * @param string $ta Répertoire temporaire accessible
2332 2331
  */
2333 2332
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2334
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2335
-	spip_initialisation_suite();
2333
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2334
+    spip_initialisation_suite();
2336 2335
 }
2337 2336
 
2338 2337
 /**
@@ -2352,322 +2351,322 @@  discard block
 block discarded – undo
2352 2351
  * @param string $ta Répertoire temporaire accessible
2353 2352
  */
2354 2353
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2355
-	static $too_late = 0;
2356
-	if ($too_late++) {
2357
-		return;
2358
-	}
2359
-
2360
-	// Declaration des repertoires
2361
-
2362
-	// le nom du repertoire plugins/ activables/desactivables
2363
-	if (!defined('_DIR_PLUGINS')) {
2364
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2365
-	}
2366
-
2367
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2368
-	if (!defined('_DIR_PLUGINS_DIST')) {
2369
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2370
-	}
2371
-
2372
-	// le nom du repertoire des librairies
2373
-	if (!defined('_DIR_LIB')) {
2374
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2375
-	}
2376
-
2377
-	if (!defined('_DIR_IMG')) {
2378
-		define('_DIR_IMG', $pa);
2379
-	}
2380
-	if (!defined('_DIR_LOGOS')) {
2381
-		define('_DIR_LOGOS', $pa);
2382
-	}
2383
-	if (!defined('_DIR_IMG_ICONES')) {
2384
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2385
-	}
2386
-
2387
-	if (!defined('_DIR_DUMP')) {
2388
-		define('_DIR_DUMP', $ti . 'dump/');
2389
-	}
2390
-	if (!defined('_DIR_SESSIONS')) {
2391
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2392
-	}
2393
-	if (!defined('_DIR_TRANSFERT')) {
2394
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2395
-	}
2396
-	if (!defined('_DIR_CACHE')) {
2397
-		define('_DIR_CACHE', $ti . 'cache/');
2398
-	}
2399
-	if (!defined('_DIR_CACHE_XML')) {
2400
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2401
-	}
2402
-	if (!defined('_DIR_SKELS')) {
2403
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2404
-	}
2405
-	if (!defined('_DIR_AIDE')) {
2406
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2407
-	}
2408
-	if (!defined('_DIR_TMP')) {
2409
-		define('_DIR_TMP', $ti);
2410
-	}
2411
-
2412
-	if (!defined('_DIR_VAR')) {
2413
-		define('_DIR_VAR', $ta);
2414
-	}
2415
-
2416
-	if (!defined('_DIR_ETC')) {
2417
-		define('_DIR_ETC', $pi);
2418
-	}
2419
-	if (!defined('_DIR_CONNECT')) {
2420
-		define('_DIR_CONNECT', $pi);
2421
-	}
2422
-	if (!defined('_DIR_CHMOD')) {
2423
-		define('_DIR_CHMOD', $pi);
2424
-	}
2425
-
2426
-	if (!isset($GLOBALS['test_dirs'])) {
2427
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2428
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2429
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2430
-	}
2431
-
2432
-	// Declaration des fichiers
2433
-
2434
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2435
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2436
-	}
2437
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2438
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2439
-	}
2440
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2441
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2442
-	}
2443
-	if (!defined('_CACHE_PIPELINES')) {
2444
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2445
-	}
2446
-	if (!defined('_CACHE_CHEMIN')) {
2447
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2448
-	}
2449
-
2450
-	# attention .php obligatoire pour ecrire_fichier_securise
2451
-	if (!defined('_FILE_META')) {
2452
-		define('_FILE_META', $ti . 'meta_cache.php');
2453
-	}
2454
-	if (!defined('_DIR_LOG')) {
2455
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2456
-	}
2457
-	if (!defined('_FILE_LOG')) {
2458
-		define('_FILE_LOG', 'spip');
2459
-	}
2460
-	if (!defined('_FILE_LOG_SUFFIX')) {
2461
-		define('_FILE_LOG_SUFFIX', '.log');
2462
-	}
2463
-
2464
-	// Le fichier de connexion a la base de donnees
2465
-	// tient compte des anciennes versions (inc_connect...)
2466
-	if (!defined('_FILE_CONNECT_INS')) {
2467
-		define('_FILE_CONNECT_INS', 'connect');
2468
-	}
2469
-	if (!defined('_FILE_CONNECT')) {
2470
-		define(
2471
-			'_FILE_CONNECT',
2472
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2473
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2474
-			: false))
2475
-		);
2476
-	}
2477
-
2478
-	// Le fichier de reglages des droits
2479
-	if (!defined('_FILE_CHMOD_INS')) {
2480
-		define('_FILE_CHMOD_INS', 'chmod');
2481
-	}
2482
-	if (!defined('_FILE_CHMOD')) {
2483
-		define(
2484
-			'_FILE_CHMOD',
2485
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2486
-			: false)
2487
-		);
2488
-	}
2489
-
2490
-	if (!defined('_FILE_LDAP')) {
2491
-		define('_FILE_LDAP', 'ldap.php');
2492
-	}
2493
-
2494
-	if (!defined('_FILE_TMP_SUFFIX')) {
2495
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2496
-	}
2497
-	if (!defined('_FILE_CONNECT_TMP')) {
2498
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2499
-	}
2500
-	if (!defined('_FILE_CHMOD_TMP')) {
2501
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2502
-	}
2503
-
2504
-	// Definition des droits d'acces en ecriture
2505
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2506
-		include_once _FILE_CHMOD;
2507
-	}
2508
-
2509
-	// Se mefier des fichiers mal remplis!
2510
-	if (!defined('_SPIP_CHMOD')) {
2511
-		define('_SPIP_CHMOD', 0777);
2512
-	}
2513
-
2514
-	if (!defined('_DEFAULT_CHARSET')) {
2515
-		/** Le charset par défaut lors de l'installation */
2516
-		define('_DEFAULT_CHARSET', 'utf-8');
2517
-	}
2518
-	if (!defined('_ROOT_PLUGINS')) {
2519
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2520
-	}
2521
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2522
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2523
-	}
2524
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2525
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2526
-	}
2527
-
2528
-	// La taille des Log
2529
-	if (!defined('_MAX_LOG')) {
2530
-		define('_MAX_LOG', 100);
2531
-	}
2532
-
2533
-	// Sommes-nous dans l'empire du Mal ?
2534
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2535
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2536
-		if (!defined('_OS_SERVEUR')) {
2537
-			define('_OS_SERVEUR', 'windows');
2538
-		}
2539
-		if (!defined('_SPIP_LOCK_MODE')) {
2540
-			define('_SPIP_LOCK_MODE', 1);
2541
-		} // utiliser le flock php
2542
-	} else {
2543
-		if (!defined('_OS_SERVEUR')) {
2544
-			define('_OS_SERVEUR', '');
2545
-		}
2546
-		if (!defined('_SPIP_LOCK_MODE')) {
2547
-			define('_SPIP_LOCK_MODE', 1);
2548
-		} // utiliser le flock php
2549
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2550
-	}
2551
-
2552
-	// Langue par defaut
2553
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2554
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2555
-	}
2556
-
2557
-	//
2558
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2559
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2560
-	// pour le rendre surchargeable, on va provoquer un reecriture
2561
-	// systematique du noyau ou une baisse de perfs => a etudier)
2562
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2563
-
2564
-	// charger tout de suite le path et son cache
2565
-	load_path_cache();
2566
-
2567
-	// *********** traiter les variables ************
2568
-
2569
-	//
2570
-	// Securite
2571
-	//
2572
-
2573
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2574
-	if (isset($_REQUEST['GLOBALS'])) {
2575
-		die();
2576
-	}
2577
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2578
-	spip_desinfecte($_GET);
2579
-	spip_desinfecte($_POST);
2580
-	spip_desinfecte($_COOKIE);
2581
-	spip_desinfecte($_REQUEST);
2582
-
2583
-	// appliquer le cookie_prefix
2584
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2585
-		include_spip('inc/cookie');
2586
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2587
-	}
2588
-
2589
-	//
2590
-	// Capacites php (en fonction de la version)
2591
-	//
2592
-	$GLOBALS['flag_ob'] = (function_exists('ob_start')
2593
-		&& function_exists('ini_get')
2594
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2595
-	$GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2596
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2597
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2598
-		(get_cfg_var('upload_max_filesize') > 0));
2599
-
2600
-
2601
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2602
-	if (isset($_SERVER['REQUEST_URI'])) {
2603
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2604
-	} else {
2605
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2606
-		if (
2607
-			!empty($_SERVER['QUERY_STRING'])
2608
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2609
-		) {
2610
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2611
-		}
2612
-	}
2613
-
2614
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2615
-	if (!defined('_RENOUVELLE_ALEA')) {
2616
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2617
-	}
2618
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2619
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2620
-	}
2621
-
2622
-	// charger les meta si possible et renouveller l'alea au besoin
2623
-	// charge aussi effacer_meta et ecrire_meta
2624
-	$inc_meta = charger_fonction('meta', 'inc');
2625
-	$inc_meta();
2626
-
2627
-	// nombre de repertoires depuis la racine
2628
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2629
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2630
-	// le calcul est faux)
2631
-	if (!_DIR_RESTREINT) {
2632
-		$GLOBALS['profondeur_url'] = 1;
2633
-	} else {
2634
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2635
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2636
-		if (
2637
-			!$uri_ref
2638
-			// si on est appele avec un autre ti, on est sans doute en mutu
2639
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2640
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2641
-			// s'en remettre a l'adresse du site. alea jacta est.
2642
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2643
-		) {
2644
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2645
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2646
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2647
-			} else {
2648
-				$uri_ref = '';
2649
-			}
2650
-		}
2651
-		if (!$uri or !$uri_ref) {
2652
-			$GLOBALS['profondeur_url'] = 0;
2653
-		} else {
2654
-			$GLOBALS['profondeur_url'] = max(
2655
-				0,
2656
-				substr_count($uri[0], '/')
2657
-				- substr_count($uri_ref, '/')
2658
-			);
2659
-		}
2660
-	}
2661
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2662
-	if (_FILE_CONNECT) {
2663
-		if (
2664
-			verifier_visiteur() == '0minirezo'
2665
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2666
-			and !isset($_COOKIE['spip_admin'])
2667
-		) {
2668
-			clear_path_cache();
2669
-		}
2670
-	}
2354
+    static $too_late = 0;
2355
+    if ($too_late++) {
2356
+        return;
2357
+    }
2358
+
2359
+    // Declaration des repertoires
2360
+
2361
+    // le nom du repertoire plugins/ activables/desactivables
2362
+    if (!defined('_DIR_PLUGINS')) {
2363
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2364
+    }
2365
+
2366
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2367
+    if (!defined('_DIR_PLUGINS_DIST')) {
2368
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2369
+    }
2370
+
2371
+    // le nom du repertoire des librairies
2372
+    if (!defined('_DIR_LIB')) {
2373
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2374
+    }
2375
+
2376
+    if (!defined('_DIR_IMG')) {
2377
+        define('_DIR_IMG', $pa);
2378
+    }
2379
+    if (!defined('_DIR_LOGOS')) {
2380
+        define('_DIR_LOGOS', $pa);
2381
+    }
2382
+    if (!defined('_DIR_IMG_ICONES')) {
2383
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2384
+    }
2385
+
2386
+    if (!defined('_DIR_DUMP')) {
2387
+        define('_DIR_DUMP', $ti . 'dump/');
2388
+    }
2389
+    if (!defined('_DIR_SESSIONS')) {
2390
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2391
+    }
2392
+    if (!defined('_DIR_TRANSFERT')) {
2393
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2394
+    }
2395
+    if (!defined('_DIR_CACHE')) {
2396
+        define('_DIR_CACHE', $ti . 'cache/');
2397
+    }
2398
+    if (!defined('_DIR_CACHE_XML')) {
2399
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2400
+    }
2401
+    if (!defined('_DIR_SKELS')) {
2402
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2403
+    }
2404
+    if (!defined('_DIR_AIDE')) {
2405
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2406
+    }
2407
+    if (!defined('_DIR_TMP')) {
2408
+        define('_DIR_TMP', $ti);
2409
+    }
2410
+
2411
+    if (!defined('_DIR_VAR')) {
2412
+        define('_DIR_VAR', $ta);
2413
+    }
2414
+
2415
+    if (!defined('_DIR_ETC')) {
2416
+        define('_DIR_ETC', $pi);
2417
+    }
2418
+    if (!defined('_DIR_CONNECT')) {
2419
+        define('_DIR_CONNECT', $pi);
2420
+    }
2421
+    if (!defined('_DIR_CHMOD')) {
2422
+        define('_DIR_CHMOD', $pi);
2423
+    }
2424
+
2425
+    if (!isset($GLOBALS['test_dirs'])) {
2426
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2427
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2428
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2429
+    }
2430
+
2431
+    // Declaration des fichiers
2432
+
2433
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2434
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2435
+    }
2436
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2437
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2438
+    }
2439
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2440
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2441
+    }
2442
+    if (!defined('_CACHE_PIPELINES')) {
2443
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2444
+    }
2445
+    if (!defined('_CACHE_CHEMIN')) {
2446
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2447
+    }
2448
+
2449
+    # attention .php obligatoire pour ecrire_fichier_securise
2450
+    if (!defined('_FILE_META')) {
2451
+        define('_FILE_META', $ti . 'meta_cache.php');
2452
+    }
2453
+    if (!defined('_DIR_LOG')) {
2454
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2455
+    }
2456
+    if (!defined('_FILE_LOG')) {
2457
+        define('_FILE_LOG', 'spip');
2458
+    }
2459
+    if (!defined('_FILE_LOG_SUFFIX')) {
2460
+        define('_FILE_LOG_SUFFIX', '.log');
2461
+    }
2462
+
2463
+    // Le fichier de connexion a la base de donnees
2464
+    // tient compte des anciennes versions (inc_connect...)
2465
+    if (!defined('_FILE_CONNECT_INS')) {
2466
+        define('_FILE_CONNECT_INS', 'connect');
2467
+    }
2468
+    if (!defined('_FILE_CONNECT')) {
2469
+        define(
2470
+            '_FILE_CONNECT',
2471
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2472
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2473
+            : false))
2474
+        );
2475
+    }
2476
+
2477
+    // Le fichier de reglages des droits
2478
+    if (!defined('_FILE_CHMOD_INS')) {
2479
+        define('_FILE_CHMOD_INS', 'chmod');
2480
+    }
2481
+    if (!defined('_FILE_CHMOD')) {
2482
+        define(
2483
+            '_FILE_CHMOD',
2484
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2485
+            : false)
2486
+        );
2487
+    }
2488
+
2489
+    if (!defined('_FILE_LDAP')) {
2490
+        define('_FILE_LDAP', 'ldap.php');
2491
+    }
2492
+
2493
+    if (!defined('_FILE_TMP_SUFFIX')) {
2494
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2495
+    }
2496
+    if (!defined('_FILE_CONNECT_TMP')) {
2497
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2498
+    }
2499
+    if (!defined('_FILE_CHMOD_TMP')) {
2500
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2501
+    }
2502
+
2503
+    // Definition des droits d'acces en ecriture
2504
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2505
+        include_once _FILE_CHMOD;
2506
+    }
2507
+
2508
+    // Se mefier des fichiers mal remplis!
2509
+    if (!defined('_SPIP_CHMOD')) {
2510
+        define('_SPIP_CHMOD', 0777);
2511
+    }
2512
+
2513
+    if (!defined('_DEFAULT_CHARSET')) {
2514
+        /** Le charset par défaut lors de l'installation */
2515
+        define('_DEFAULT_CHARSET', 'utf-8');
2516
+    }
2517
+    if (!defined('_ROOT_PLUGINS')) {
2518
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2519
+    }
2520
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2521
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2522
+    }
2523
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2524
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2525
+    }
2526
+
2527
+    // La taille des Log
2528
+    if (!defined('_MAX_LOG')) {
2529
+        define('_MAX_LOG', 100);
2530
+    }
2531
+
2532
+    // Sommes-nous dans l'empire du Mal ?
2533
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2534
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2535
+        if (!defined('_OS_SERVEUR')) {
2536
+            define('_OS_SERVEUR', 'windows');
2537
+        }
2538
+        if (!defined('_SPIP_LOCK_MODE')) {
2539
+            define('_SPIP_LOCK_MODE', 1);
2540
+        } // utiliser le flock php
2541
+    } else {
2542
+        if (!defined('_OS_SERVEUR')) {
2543
+            define('_OS_SERVEUR', '');
2544
+        }
2545
+        if (!defined('_SPIP_LOCK_MODE')) {
2546
+            define('_SPIP_LOCK_MODE', 1);
2547
+        } // utiliser le flock php
2548
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2549
+    }
2550
+
2551
+    // Langue par defaut
2552
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2553
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2554
+    }
2555
+
2556
+    //
2557
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2558
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2559
+    // pour le rendre surchargeable, on va provoquer un reecriture
2560
+    // systematique du noyau ou une baisse de perfs => a etudier)
2561
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2562
+
2563
+    // charger tout de suite le path et son cache
2564
+    load_path_cache();
2565
+
2566
+    // *********** traiter les variables ************
2567
+
2568
+    //
2569
+    // Securite
2570
+    //
2571
+
2572
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2573
+    if (isset($_REQUEST['GLOBALS'])) {
2574
+        die();
2575
+    }
2576
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2577
+    spip_desinfecte($_GET);
2578
+    spip_desinfecte($_POST);
2579
+    spip_desinfecte($_COOKIE);
2580
+    spip_desinfecte($_REQUEST);
2581
+
2582
+    // appliquer le cookie_prefix
2583
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2584
+        include_spip('inc/cookie');
2585
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2586
+    }
2587
+
2588
+    //
2589
+    // Capacites php (en fonction de la version)
2590
+    //
2591
+    $GLOBALS['flag_ob'] = (function_exists('ob_start')
2592
+        && function_exists('ini_get')
2593
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2594
+    $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2595
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2596
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2597
+        (get_cfg_var('upload_max_filesize') > 0));
2598
+
2599
+
2600
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2601
+    if (isset($_SERVER['REQUEST_URI'])) {
2602
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2603
+    } else {
2604
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2605
+        if (
2606
+            !empty($_SERVER['QUERY_STRING'])
2607
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2608
+        ) {
2609
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2610
+        }
2611
+    }
2612
+
2613
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2614
+    if (!defined('_RENOUVELLE_ALEA')) {
2615
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2616
+    }
2617
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2618
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2619
+    }
2620
+
2621
+    // charger les meta si possible et renouveller l'alea au besoin
2622
+    // charge aussi effacer_meta et ecrire_meta
2623
+    $inc_meta = charger_fonction('meta', 'inc');
2624
+    $inc_meta();
2625
+
2626
+    // nombre de repertoires depuis la racine
2627
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2628
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2629
+    // le calcul est faux)
2630
+    if (!_DIR_RESTREINT) {
2631
+        $GLOBALS['profondeur_url'] = 1;
2632
+    } else {
2633
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2634
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
2635
+        if (
2636
+            !$uri_ref
2637
+            // si on est appele avec un autre ti, on est sans doute en mutu
2638
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2639
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2640
+            // s'en remettre a l'adresse du site. alea jacta est.
2641
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2642
+        ) {
2643
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2644
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2645
+                $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2646
+            } else {
2647
+                $uri_ref = '';
2648
+            }
2649
+        }
2650
+        if (!$uri or !$uri_ref) {
2651
+            $GLOBALS['profondeur_url'] = 0;
2652
+        } else {
2653
+            $GLOBALS['profondeur_url'] = max(
2654
+                0,
2655
+                substr_count($uri[0], '/')
2656
+                - substr_count($uri_ref, '/')
2657
+            );
2658
+        }
2659
+    }
2660
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2661
+    if (_FILE_CONNECT) {
2662
+        if (
2663
+            verifier_visiteur() == '0minirezo'
2664
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2665
+            and !isset($_COOKIE['spip_admin'])
2666
+        ) {
2667
+            clear_path_cache();
2668
+        }
2669
+    }
2671 2670
 }
2672 2671
 
2673 2672
 /**
@@ -2676,190 +2675,190 @@  discard block
 block discarded – undo
2676 2675
  *
2677 2676
  */
2678 2677
 function spip_initialisation_suite() {
2679
-	static $too_late = 0;
2680
-	if ($too_late++) {
2681
-		return;
2682
-	}
2683
-
2684
-	// taille mini des login
2685
-	if (!defined('_LOGIN_TROP_COURT')) {
2686
-		define('_LOGIN_TROP_COURT', 4);
2687
-	}
2688
-
2689
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2690
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2691
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2692
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2693
-
2694
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2695
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2696
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2697
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2698
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2699
-
2700
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2701
-		define('_PASS_LONGUEUR_MINI', 6);
2702
-	}
2703
-
2704
-	// largeur maximale des images dans l'administration
2705
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2706
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2707
-	}
2708
-
2709
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2710
-	if (!defined('_IMG_QUALITE')) {
2711
-		define('_IMG_QUALITE', 85);
2712
-	} # valeur par defaut
2713
-	if (!defined('_IMG_GD_QUALITE')) {
2714
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2715
-	} # surcharge pour la lib GD
2716
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2717
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2718
-	} # surcharge pour imagick en ligne de commande
2719
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2720
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2721
-		define('_IMG_IMAGICK_QUALITE', 75);
2722
-	} # surcharge pour imagick en PHP
2723
-
2724
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2725
-		define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2726
-	} // poids en octet
2727
-
2728
-	// qq chaines standard
2729
-	if (!defined('_ACCESS_FILE_NAME')) {
2730
-		define('_ACCESS_FILE_NAME', '.htaccess');
2731
-	}
2732
-	if (!defined('_AUTH_USER_FILE')) {
2733
-		define('_AUTH_USER_FILE', '.htpasswd');
2734
-	}
2735
-	if (!defined('_SPIP_DUMP')) {
2736
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2737
-	}
2738
-	if (!defined('_CACHE_RUBRIQUES')) {
2739
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2740
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2741
-	}
2742
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2743
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2744
-		define('_CACHE_RUBRIQUES_MAX', 500);
2745
-	}
2746
-
2747
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2748
-		/**
2749
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2750
-		 * @var int Nombre de caractères */
2751
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2752
-	}
2753
-
2754
-	if (!defined('_EXTENSION_SQUELETTES')) {
2755
-		define('_EXTENSION_SQUELETTES', 'html');
2756
-	}
2757
-
2758
-	if (!defined('_DOCTYPE_ECRIRE')) {
2759
-		/** Définit le doctype de l’espace privé */
2760
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2761
-	}
2762
-	if (!defined('_DOCTYPE_AIDE')) {
2763
-		/** Définit le doctype de l’aide en ligne */
2764
-		define(
2765
-			'_DOCTYPE_AIDE',
2766
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2767
-		);
2768
-	}
2769
-
2770
-	if (!defined('_SPIP_SCRIPT')) {
2771
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2772
-		 * le script de l'espace public, alias index.php */
2773
-		define('_SPIP_SCRIPT', 'spip.php');
2774
-	}
2775
-	if (!defined('_SPIP_PAGE')) {
2776
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2777
-		define('_SPIP_PAGE', 'page');
2778
-	}
2779
-
2780
-	// le script de l'espace prive
2781
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2782
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2783
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2784
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2785
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2786
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2787
-		} else {
2788
-			define('_SPIP_ECRIRE_SCRIPT', '');
2789
-		}
2790
-	}
2791
-
2792
-
2793
-	if (!defined('_SPIP_AJAX')) {
2794
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2795
-			? 1
2796
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2797
-	}
2798
-
2799
-	// La requete est-elle en ajax ?
2800
-	if (!defined('_AJAX')) {
2801
-		define(
2802
-			'_AJAX',
2803
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2804
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2805
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2806
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2807
-			)
2808
-			and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2809
-		);
2810
-	}
2811
-
2812
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2813
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2814
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2815
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2816
-		define(
2817
-			'_IMG_GD_MAX_PIXELS',
2818
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2819
-			? $GLOBALS['meta']['max_taille_vignettes']
2820
-			: 0
2821
-		);
2822
-	}
2823
-
2824
-	if (!defined('_MEMORY_LIMIT_MIN')) {
2825
-		define('_MEMORY_LIMIT_MIN', 16);
2826
-	} // en Mo
2827
-	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2828
-	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2829
-	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2830
-	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2831
-		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2832
-			$unit = strtolower(substr($memory, -1));
2833
-			$memory = substr($memory, 0, -1);
2834
-			switch ($unit) {
2835
-				// Le modifieur 'G' est disponible depuis PHP 5.1.0
2836
-				case 'g':
2837
-					$memory *= 1024;
2838
-				case 'm':
2839
-					$memory *= 1024;
2840
-				case 'k':
2841
-					$memory *= 1024;
2842
-			}
2843
-			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2844
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2845
-				if (trim(ini_get('memory_limit')) != $m) {
2846
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2847
-						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2848
-					} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2849
-				}
2850
-			}
2851
-		} else {
2852
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2853
-				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2854
-			}
2855
-		} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2856
-	}
2857
-	// Protocoles a normaliser dans les chaines de langues
2858
-	if (!defined('_PROTOCOLES_STD')) {
2859
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2860
-	}
2861
-
2862
-	init_var_mode();
2678
+    static $too_late = 0;
2679
+    if ($too_late++) {
2680
+        return;
2681
+    }
2682
+
2683
+    // taille mini des login
2684
+    if (!defined('_LOGIN_TROP_COURT')) {
2685
+        define('_LOGIN_TROP_COURT', 4);
2686
+    }
2687
+
2688
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2689
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2690
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2691
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2692
+
2693
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2694
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2695
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2696
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2697
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2698
+
2699
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2700
+        define('_PASS_LONGUEUR_MINI', 6);
2701
+    }
2702
+
2703
+    // largeur maximale des images dans l'administration
2704
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2705
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
2706
+    }
2707
+
2708
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2709
+    if (!defined('_IMG_QUALITE')) {
2710
+        define('_IMG_QUALITE', 85);
2711
+    } # valeur par defaut
2712
+    if (!defined('_IMG_GD_QUALITE')) {
2713
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2714
+    } # surcharge pour la lib GD
2715
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2716
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2717
+    } # surcharge pour imagick en ligne de commande
2718
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2719
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2720
+        define('_IMG_IMAGICK_QUALITE', 75);
2721
+    } # surcharge pour imagick en PHP
2722
+
2723
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2724
+        define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2725
+    } // poids en octet
2726
+
2727
+    // qq chaines standard
2728
+    if (!defined('_ACCESS_FILE_NAME')) {
2729
+        define('_ACCESS_FILE_NAME', '.htaccess');
2730
+    }
2731
+    if (!defined('_AUTH_USER_FILE')) {
2732
+        define('_AUTH_USER_FILE', '.htpasswd');
2733
+    }
2734
+    if (!defined('_SPIP_DUMP')) {
2735
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2736
+    }
2737
+    if (!defined('_CACHE_RUBRIQUES')) {
2738
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2739
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2740
+    }
2741
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2742
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2743
+        define('_CACHE_RUBRIQUES_MAX', 500);
2744
+    }
2745
+
2746
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2747
+        /**
2748
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2749
+         * @var int Nombre de caractères */
2750
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2751
+    }
2752
+
2753
+    if (!defined('_EXTENSION_SQUELETTES')) {
2754
+        define('_EXTENSION_SQUELETTES', 'html');
2755
+    }
2756
+
2757
+    if (!defined('_DOCTYPE_ECRIRE')) {
2758
+        /** Définit le doctype de l’espace privé */
2759
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2760
+    }
2761
+    if (!defined('_DOCTYPE_AIDE')) {
2762
+        /** Définit le doctype de l’aide en ligne */
2763
+        define(
2764
+            '_DOCTYPE_AIDE',
2765
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2766
+        );
2767
+    }
2768
+
2769
+    if (!defined('_SPIP_SCRIPT')) {
2770
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2771
+         * le script de l'espace public, alias index.php */
2772
+        define('_SPIP_SCRIPT', 'spip.php');
2773
+    }
2774
+    if (!defined('_SPIP_PAGE')) {
2775
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2776
+        define('_SPIP_PAGE', 'page');
2777
+    }
2778
+
2779
+    // le script de l'espace prive
2780
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2781
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2782
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2783
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2784
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2785
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2786
+        } else {
2787
+            define('_SPIP_ECRIRE_SCRIPT', '');
2788
+        }
2789
+    }
2790
+
2791
+
2792
+    if (!defined('_SPIP_AJAX')) {
2793
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2794
+            ? 1
2795
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2796
+    }
2797
+
2798
+    // La requete est-elle en ajax ?
2799
+    if (!defined('_AJAX')) {
2800
+        define(
2801
+            '_AJAX',
2802
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2803
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2804
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2805
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2806
+            )
2807
+            and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2808
+        );
2809
+    }
2810
+
2811
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2812
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2813
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2814
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2815
+        define(
2816
+            '_IMG_GD_MAX_PIXELS',
2817
+            (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2818
+            ? $GLOBALS['meta']['max_taille_vignettes']
2819
+            : 0
2820
+        );
2821
+    }
2822
+
2823
+    if (!defined('_MEMORY_LIMIT_MIN')) {
2824
+        define('_MEMORY_LIMIT_MIN', 16);
2825
+    } // en Mo
2826
+    // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2827
+    // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2828
+    // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2829
+    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2830
+        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2831
+            $unit = strtolower(substr($memory, -1));
2832
+            $memory = substr($memory, 0, -1);
2833
+            switch ($unit) {
2834
+                // Le modifieur 'G' est disponible depuis PHP 5.1.0
2835
+                case 'g':
2836
+                    $memory *= 1024;
2837
+                case 'm':
2838
+                    $memory *= 1024;
2839
+                case 'k':
2840
+                    $memory *= 1024;
2841
+            }
2842
+            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2843
+                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2844
+                if (trim(ini_get('memory_limit')) != $m) {
2845
+                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2846
+                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2847
+                    } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2848
+                }
2849
+            }
2850
+        } else {
2851
+            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2852
+                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2853
+            }
2854
+        } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2855
+    }
2856
+    // Protocoles a normaliser dans les chaines de langues
2857
+    if (!defined('_PROTOCOLES_STD')) {
2858
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2859
+    }
2860
+
2861
+    init_var_mode();
2863 2862
 }
2864 2863
 
2865 2864
 /**
@@ -2893,136 +2892,136 @@  discard block
 block discarded – undo
2893 2892
  * `   var_mode` (calcul ou recalcul).
2894 2893
  */
2895 2894
 function init_var_mode() {
2896
-	static $done = false;
2897
-	if (!$done) {
2898
-		if (isset($_GET['var_mode'])) {
2899
-			$var_mode = explode(',', $_GET['var_mode']);
2900
-			// tout le monde peut calcul/recalcul
2901
-			if (!defined('_VAR_MODE')) {
2902
-				if (in_array('recalcul', $var_mode)) {
2903
-					define('_VAR_MODE', 'recalcul');
2904
-				} elseif (in_array('calcul', $var_mode)) {
2905
-					define('_VAR_MODE', 'calcul');
2906
-				}
2907
-			}
2908
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
2909
-			if ($var_mode) {
2910
-				include_spip('inc/autoriser');
2911
-				// autoriser preview si preview seulement, et sinon autoriser debug
2912
-				if (
2913
-					autoriser(
2914
-						($_GET['var_mode'] == 'preview')
2915
-						? 'previsualiser'
2916
-						: 'debug'
2917
-					)
2918
-				) {
2919
-					if (in_array('traduction', $var_mode)) {
2920
-						// forcer le calcul pour passer dans traduire
2921
-						if (!defined('_VAR_MODE')) {
2922
-							define('_VAR_MODE', 'calcul');
2923
-						}
2924
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2925
-						if (!defined('_VAR_NOCACHE')) {
2926
-							define('_VAR_NOCACHE', true);
2927
-						}
2928
-						$var_mode = array_diff($var_mode, ['traduction']);
2929
-					}
2930
-					if (in_array('preview', $var_mode)) {
2931
-						// basculer sur les criteres de preview dans les boucles
2932
-						if (!defined('_VAR_PREVIEW')) {
2933
-							define('_VAR_PREVIEW', true);
2934
-						}
2935
-						// forcer le calcul
2936
-						if (!defined('_VAR_MODE')) {
2937
-							define('_VAR_MODE', 'calcul');
2938
-						}
2939
-						// et ne pas enregistrer de cache
2940
-						if (!defined('_VAR_NOCACHE')) {
2941
-							define('_VAR_NOCACHE', true);
2942
-						}
2943
-						$var_mode = array_diff($var_mode, ['preview']);
2944
-					}
2945
-					if (in_array('inclure', $var_mode)) {
2946
-						// forcer le compilo et ignorer les caches existants
2947
-						if (!defined('_VAR_MODE')) {
2948
-							define('_VAR_MODE', 'calcul');
2949
-						}
2950
-						if (!defined('_VAR_INCLURE')) {
2951
-							define('_VAR_INCLURE', true);
2952
-						}
2953
-						// et ne pas enregistrer de cache
2954
-						if (!defined('_VAR_NOCACHE')) {
2955
-							define('_VAR_NOCACHE', true);
2956
-						}
2957
-						$var_mode = array_diff($var_mode, ['inclure']);
2958
-					}
2959
-					if (in_array('urls', $var_mode)) {
2960
-						// forcer le compilo et ignorer les caches existants
2961
-						if (!defined('_VAR_MODE')) {
2962
-							define('_VAR_MODE', 'calcul');
2963
-						}
2964
-						if (!defined('_VAR_URLS')) {
2965
-							define('_VAR_URLS', true);
2966
-						}
2967
-						$var_mode = array_diff($var_mode, ['urls']);
2968
-					}
2969
-					if (in_array('images', $var_mode)) {
2970
-						// forcer le compilo et ignorer les caches existants
2971
-						if (!defined('_VAR_MODE')) {
2972
-							define('_VAR_MODE', 'calcul');
2973
-						}
2974
-						// indiquer qu'on doit recalculer les images
2975
-						if (!defined('_VAR_IMAGES')) {
2976
-							define('_VAR_IMAGES', true);
2977
-						}
2978
-						$var_mode = array_diff($var_mode, ['images']);
2979
-					}
2980
-					if (in_array('debug', $var_mode)) {
2981
-						if (!defined('_VAR_MODE')) {
2982
-							define('_VAR_MODE', 'debug');
2983
-						}
2984
-						// et ne pas enregistrer de cache
2985
-						if (!defined('_VAR_NOCACHE')) {
2986
-							define('_VAR_NOCACHE', true);
2987
-						}
2988
-						$var_mode = array_diff($var_mode, ['debug']);
2989
-					}
2990
-					if (count($var_mode) and !defined('_VAR_MODE')) {
2991
-						define('_VAR_MODE', reset($var_mode));
2992
-					}
2993
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
2994
-						spip_log($GLOBALS['visiteur_session']['nom']
2995
-							. ' ' . _VAR_MODE);
2996
-					}
2997
-				} // pas autorise ?
2998
-				else {
2999
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3000
-					if (
3001
-						!$GLOBALS['visiteur_session']
3002
-						and !empty($_SERVER['HTTP_HOST'])
3003
-						and !empty($_SERVER['REQUEST_METHOD'])
3004
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3005
-					) {
3006
-						$self = self('&', true);
3007
-						if (strpos($self, 'page=login') === false) {
3008
-							include_spip('inc/headers');
3009
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3010
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3011
-						}
3012
-					}
3013
-					// sinon tant pis
3014
-				}
3015
-			}
3016
-		}
3017
-		if (!defined('_VAR_MODE')) {
3018
-			/**
3019
-			 * Indique le mode de calcul ou d'affichage de la page.
3020
-			 * @see init_var_mode()
3021
-			 */
3022
-			define('_VAR_MODE', false);
3023
-		}
3024
-		$done = true;
3025
-	}
2895
+    static $done = false;
2896
+    if (!$done) {
2897
+        if (isset($_GET['var_mode'])) {
2898
+            $var_mode = explode(',', $_GET['var_mode']);
2899
+            // tout le monde peut calcul/recalcul
2900
+            if (!defined('_VAR_MODE')) {
2901
+                if (in_array('recalcul', $var_mode)) {
2902
+                    define('_VAR_MODE', 'recalcul');
2903
+                } elseif (in_array('calcul', $var_mode)) {
2904
+                    define('_VAR_MODE', 'calcul');
2905
+                }
2906
+            }
2907
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
2908
+            if ($var_mode) {
2909
+                include_spip('inc/autoriser');
2910
+                // autoriser preview si preview seulement, et sinon autoriser debug
2911
+                if (
2912
+                    autoriser(
2913
+                        ($_GET['var_mode'] == 'preview')
2914
+                        ? 'previsualiser'
2915
+                        : 'debug'
2916
+                    )
2917
+                ) {
2918
+                    if (in_array('traduction', $var_mode)) {
2919
+                        // forcer le calcul pour passer dans traduire
2920
+                        if (!defined('_VAR_MODE')) {
2921
+                            define('_VAR_MODE', 'calcul');
2922
+                        }
2923
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2924
+                        if (!defined('_VAR_NOCACHE')) {
2925
+                            define('_VAR_NOCACHE', true);
2926
+                        }
2927
+                        $var_mode = array_diff($var_mode, ['traduction']);
2928
+                    }
2929
+                    if (in_array('preview', $var_mode)) {
2930
+                        // basculer sur les criteres de preview dans les boucles
2931
+                        if (!defined('_VAR_PREVIEW')) {
2932
+                            define('_VAR_PREVIEW', true);
2933
+                        }
2934
+                        // forcer le calcul
2935
+                        if (!defined('_VAR_MODE')) {
2936
+                            define('_VAR_MODE', 'calcul');
2937
+                        }
2938
+                        // et ne pas enregistrer de cache
2939
+                        if (!defined('_VAR_NOCACHE')) {
2940
+                            define('_VAR_NOCACHE', true);
2941
+                        }
2942
+                        $var_mode = array_diff($var_mode, ['preview']);
2943
+                    }
2944
+                    if (in_array('inclure', $var_mode)) {
2945
+                        // forcer le compilo et ignorer les caches existants
2946
+                        if (!defined('_VAR_MODE')) {
2947
+                            define('_VAR_MODE', 'calcul');
2948
+                        }
2949
+                        if (!defined('_VAR_INCLURE')) {
2950
+                            define('_VAR_INCLURE', true);
2951
+                        }
2952
+                        // et ne pas enregistrer de cache
2953
+                        if (!defined('_VAR_NOCACHE')) {
2954
+                            define('_VAR_NOCACHE', true);
2955
+                        }
2956
+                        $var_mode = array_diff($var_mode, ['inclure']);
2957
+                    }
2958
+                    if (in_array('urls', $var_mode)) {
2959
+                        // forcer le compilo et ignorer les caches existants
2960
+                        if (!defined('_VAR_MODE')) {
2961
+                            define('_VAR_MODE', 'calcul');
2962
+                        }
2963
+                        if (!defined('_VAR_URLS')) {
2964
+                            define('_VAR_URLS', true);
2965
+                        }
2966
+                        $var_mode = array_diff($var_mode, ['urls']);
2967
+                    }
2968
+                    if (in_array('images', $var_mode)) {
2969
+                        // forcer le compilo et ignorer les caches existants
2970
+                        if (!defined('_VAR_MODE')) {
2971
+                            define('_VAR_MODE', 'calcul');
2972
+                        }
2973
+                        // indiquer qu'on doit recalculer les images
2974
+                        if (!defined('_VAR_IMAGES')) {
2975
+                            define('_VAR_IMAGES', true);
2976
+                        }
2977
+                        $var_mode = array_diff($var_mode, ['images']);
2978
+                    }
2979
+                    if (in_array('debug', $var_mode)) {
2980
+                        if (!defined('_VAR_MODE')) {
2981
+                            define('_VAR_MODE', 'debug');
2982
+                        }
2983
+                        // et ne pas enregistrer de cache
2984
+                        if (!defined('_VAR_NOCACHE')) {
2985
+                            define('_VAR_NOCACHE', true);
2986
+                        }
2987
+                        $var_mode = array_diff($var_mode, ['debug']);
2988
+                    }
2989
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
2990
+                        define('_VAR_MODE', reset($var_mode));
2991
+                    }
2992
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
2993
+                        spip_log($GLOBALS['visiteur_session']['nom']
2994
+                            . ' ' . _VAR_MODE);
2995
+                    }
2996
+                } // pas autorise ?
2997
+                else {
2998
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
2999
+                    if (
3000
+                        !$GLOBALS['visiteur_session']
3001
+                        and !empty($_SERVER['HTTP_HOST'])
3002
+                        and !empty($_SERVER['REQUEST_METHOD'])
3003
+                        and $_SERVER['REQUEST_METHOD'] === 'GET'
3004
+                    ) {
3005
+                        $self = self('&', true);
3006
+                        if (strpos($self, 'page=login') === false) {
3007
+                            include_spip('inc/headers');
3008
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3009
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3010
+                        }
3011
+                    }
3012
+                    // sinon tant pis
3013
+                }
3014
+            }
3015
+        }
3016
+        if (!defined('_VAR_MODE')) {
3017
+            /**
3018
+             * Indique le mode de calcul ou d'affichage de la page.
3019
+             * @see init_var_mode()
3020
+             */
3021
+            define('_VAR_MODE', false);
3022
+        }
3023
+        $done = true;
3024
+    }
3026 3025
 }
3027 3026
 
3028 3027
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
@@ -3030,84 +3029,84 @@  discard block
 block discarded – undo
3030 3029
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
3031 3030
 // https://code.spip.net/@spip_desinfecte
3032 3031
 function spip_desinfecte(&$t, $deep = true) {
3033
-	foreach ($t as $key => $val) {
3034
-		if (is_string($t[$key])) {
3035
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3036
-		} // traiter aussi les "texte_plus" de article_edit
3037
-		else {
3038
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3039
-				spip_desinfecte($t[$key], $deep);
3040
-			}
3041
-		}
3042
-	}
3032
+    foreach ($t as $key => $val) {
3033
+        if (is_string($t[$key])) {
3034
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3035
+        } // traiter aussi les "texte_plus" de article_edit
3036
+        else {
3037
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3038
+                spip_desinfecte($t[$key], $deep);
3039
+            }
3040
+        }
3041
+    }
3043 3042
 }
3044 3043
 
3045 3044
 //  retourne le statut du visiteur s'il s'annonce
3046 3045
 
3047 3046
 // https://code.spip.net/@verifier_visiteur
3048 3047
 function verifier_visiteur() {
3049
-	// Rq: pour que cette fonction marche depuis mes_options
3050
-	// il faut forcer l'init si ce n'est fait
3051
-	// mais on risque de perturber des plugins en initialisant trop tot
3052
-	// certaines constantes
3053
-	@spip_initialisation_core(
3054
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3055
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3056
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3057
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3058
-	);
3059
-
3060
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3061
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3062
-	// Attention on separe bien session_nom et nom, pour eviter
3063
-	// les melanges entre donnees SQL et variables plus aleatoires
3064
-	$variables_session = ['session_nom', 'session_email'];
3065
-	foreach ($variables_session as $var) {
3066
-		if (_request($var) !== null) {
3067
-			$init = true;
3068
-			break;
3069
-		}
3070
-	}
3071
-	if (isset($init)) {
3072
-		#@spip_initialisation_suite();
3073
-		$session = charger_fonction('session', 'inc');
3074
-		$session();
3075
-		include_spip('inc/texte');
3076
-		foreach ($variables_session as $var) {
3077
-			if (($a = _request($var)) !== null) {
3078
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3079
-			}
3080
-		}
3081
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3082
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3083
-		}
3084
-		$session($GLOBALS['visiteur_session']);
3085
-
3086
-		return 0;
3087
-	}
3088
-
3089
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3090
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3091
-		$session = charger_fonction('session', 'inc');
3092
-		if ($session()) {
3093
-			return $GLOBALS['visiteur_session']['statut'];
3094
-		}
3095
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3096
-			include_spip('inc/auth');
3097
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3098
-		}
3099
-		if ($h) {
3100
-			$GLOBALS['visiteur_session'] = $h;
3101
-
3102
-			return $GLOBALS['visiteur_session']['statut'];
3103
-		}
3104
-	}
3105
-
3106
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3107
-	include_spip('inc/lang');
3108
-	utiliser_langue_visiteur();
3109
-
3110
-	return false;
3048
+    // Rq: pour que cette fonction marche depuis mes_options
3049
+    // il faut forcer l'init si ce n'est fait
3050
+    // mais on risque de perturber des plugins en initialisant trop tot
3051
+    // certaines constantes
3052
+    @spip_initialisation_core(
3053
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3054
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3055
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3056
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3057
+    );
3058
+
3059
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3060
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3061
+    // Attention on separe bien session_nom et nom, pour eviter
3062
+    // les melanges entre donnees SQL et variables plus aleatoires
3063
+    $variables_session = ['session_nom', 'session_email'];
3064
+    foreach ($variables_session as $var) {
3065
+        if (_request($var) !== null) {
3066
+            $init = true;
3067
+            break;
3068
+        }
3069
+    }
3070
+    if (isset($init)) {
3071
+        #@spip_initialisation_suite();
3072
+        $session = charger_fonction('session', 'inc');
3073
+        $session();
3074
+        include_spip('inc/texte');
3075
+        foreach ($variables_session as $var) {
3076
+            if (($a = _request($var)) !== null) {
3077
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3078
+            }
3079
+        }
3080
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3081
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3082
+        }
3083
+        $session($GLOBALS['visiteur_session']);
3084
+
3085
+        return 0;
3086
+    }
3087
+
3088
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3089
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3090
+        $session = charger_fonction('session', 'inc');
3091
+        if ($session()) {
3092
+            return $GLOBALS['visiteur_session']['statut'];
3093
+        }
3094
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3095
+            include_spip('inc/auth');
3096
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3097
+        }
3098
+        if ($h) {
3099
+            $GLOBALS['visiteur_session'] = $h;
3100
+
3101
+            return $GLOBALS['visiteur_session']['statut'];
3102
+        }
3103
+    }
3104
+
3105
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3106
+    include_spip('inc/lang');
3107
+    utiliser_langue_visiteur();
3108
+
3109
+    return false;
3111 3110
 }
3112 3111
 
3113 3112
 
@@ -3130,21 +3129,21 @@  discard block
 block discarded – undo
3130 3129
  *     - string Langue utilisée.
3131 3130
  **/
3132 3131
 function lang_select($lang = null) {
3133
-	static $pile_langues = [];
3134
-	if (!function_exists('changer_langue')) {
3135
-		include_spip('inc/lang');
3136
-	}
3137
-	if ($lang === null) {
3138
-		$lang = array_pop($pile_langues);
3139
-	} else {
3140
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3141
-	}
3142
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3143
-		return $lang;
3144
-	}
3145
-	changer_langue($lang);
3132
+    static $pile_langues = [];
3133
+    if (!function_exists('changer_langue')) {
3134
+        include_spip('inc/lang');
3135
+    }
3136
+    if ($lang === null) {
3137
+        $lang = array_pop($pile_langues);
3138
+    } else {
3139
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3140
+    }
3141
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3142
+        return $lang;
3143
+    }
3144
+    changer_langue($lang);
3146 3145
 
3147
-	return $lang;
3146
+    return $lang;
3148 3147
 }
3149 3148
 
3150 3149
 /**
@@ -3161,20 +3160,20 @@  discard block
 block discarded – undo
3161 3160
  *     Identifiant de la session
3162 3161
  **/
3163 3162
 function spip_session($force = false) {
3164
-	static $session;
3165
-	if ($force or !isset($session)) {
3166
-		$s = pipeline(
3167
-			'definir_session',
3168
-			$GLOBALS['visiteur_session']
3169
-				? serialize($GLOBALS['visiteur_session'])
3170
-				. '_' . @$_COOKIE['spip_session']
3171
-				: ''
3172
-		);
3173
-		$session = $s ? substr(md5($s), 0, 8) : '';
3174
-	}
3163
+    static $session;
3164
+    if ($force or !isset($session)) {
3165
+        $s = pipeline(
3166
+            'definir_session',
3167
+            $GLOBALS['visiteur_session']
3168
+                ? serialize($GLOBALS['visiteur_session'])
3169
+                . '_' . @$_COOKIE['spip_session']
3170
+                : ''
3171
+        );
3172
+        $session = $s ? substr(md5($s), 0, 8) : '';
3173
+    }
3175 3174
 
3176
-	#spip_log('session: '.$session);
3177
-	return $session;
3175
+    #spip_log('session: '.$session);
3176
+    return $session;
3178 3177
 }
3179 3178
 
3180 3179
 
@@ -3193,9 +3192,9 @@  discard block
 block discarded – undo
3193 3192
  *    Lien sur une icone d'aide
3194 3193
  **/
3195 3194
 function aider($aide = '', $distante = false) {
3196
-	$aider = charger_fonction('aide', 'inc', true);
3195
+    $aider = charger_fonction('aide', 'inc', true);
3197 3196
 
3198
-	return $aider ? $aider($aide, '', [], $distante) : '';
3197
+    return $aider ? $aider($aide, '', [], $distante) : '';
3199 3198
 }
3200 3199
 
3201 3200
 /**
@@ -3205,24 +3204,24 @@  discard block
 block discarded – undo
3205 3204
  */
3206 3205
 function exec_info_dist() {
3207 3206
 
3208
-	include_spip('inc/autoriser');
3209
-	if (autoriser('phpinfos')) {
3210
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3211
-		$cookies_backup = [];
3212
-		foreach ($cookies_masques as $k) {
3213
-			if (!empty($_COOKIE[$k])) {
3214
-				$cookies_backup[$k] = $_COOKIE[$k];
3215
-				$_COOKIE[$k] = '******************************';
3216
-			}
3217
-		}
3218
-		phpinfo();
3219
-		foreach ($cookies_backup as $k => $v) {
3220
-			$_COOKIE[$k] = $v;
3221
-		}
3222
-	} else {
3223
-		include_spip('inc/filtres');
3224
-		sinon_interdire_acces();
3225
-	}
3207
+    include_spip('inc/autoriser');
3208
+    if (autoriser('phpinfos')) {
3209
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3210
+        $cookies_backup = [];
3211
+        foreach ($cookies_masques as $k) {
3212
+            if (!empty($_COOKIE[$k])) {
3213
+                $cookies_backup[$k] = $_COOKIE[$k];
3214
+                $_COOKIE[$k] = '******************************';
3215
+            }
3216
+        }
3217
+        phpinfo();
3218
+        foreach ($cookies_backup as $k => $v) {
3219
+            $_COOKIE[$k] = $v;
3220
+        }
3221
+    } else {
3222
+        include_spip('inc/filtres');
3223
+        sinon_interdire_acces();
3224
+    }
3226 3225
 }
3227 3226
 
3228 3227
 /**
@@ -3242,13 +3241,13 @@  discard block
 block discarded – undo
3242 3241
  *     - string si $message à false.
3243 3242
  **/
3244 3243
 function erreur_squelette($message = '', $lieu = '') {
3245
-	$debusquer = charger_fonction('debusquer', 'public');
3246
-	if (is_array($lieu)) {
3247
-		include_spip('public/compiler');
3248
-		$lieu = reconstruire_contexte_compil($lieu);
3249
-	}
3244
+    $debusquer = charger_fonction('debusquer', 'public');
3245
+    if (is_array($lieu)) {
3246
+        include_spip('public/compiler');
3247
+        $lieu = reconstruire_contexte_compil($lieu);
3248
+    }
3250 3249
 
3251
-	return $debusquer($message, $lieu);
3250
+    return $debusquer($message, $lieu);
3252 3251
 }
3253 3252
 
3254 3253
 /**
@@ -3285,108 +3284,108 @@  discard block
 block discarded – undo
3285 3284
  *     - ou tableau d'information sur le squelette.
3286 3285
  */
3287 3286
 function recuperer_fond($fond, $contexte = [], $options = [], $connect = '') {
3288
-	if (!function_exists('evaluer_fond')) {
3289
-		include_spip('public/assembler');
3290
-	}
3291
-	// assurer la compat avec l'ancienne syntaxe
3292
-	// (trim etait le 3eme argument, par defaut a true)
3293
-	if (!is_array($options)) {
3294
-		$options = ['trim' => $options];
3295
-	}
3296
-	if (!isset($options['trim'])) {
3297
-		$options['trim'] = true;
3298
-	}
3299
-
3300
-	if (isset($contexte['connect'])) {
3301
-		$connect = $contexte['connect'];
3302
-		unset($contexte['connect']);
3303
-	}
3304
-
3305
-	$texte = '';
3306
-	$pages = [];
3307
-	$lang_select = '';
3308
-	if (!isset($options['etoile']) or !$options['etoile']) {
3309
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3310
-		if (!isset($contexte['lang'])) {
3311
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3312
-		}
3313
-
3314
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3315
-			$lang_select = lang_select($contexte['lang']);
3316
-		}
3317
-	}
3318
-
3319
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3320
-		$GLOBALS['_INC_PUBLIC'] = 0;
3321
-	}
3322
-
3323
-	$GLOBALS['_INC_PUBLIC']++;
3324
-
3325
-	// fix #4235
3326
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3327
-
3328
-
3329
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3330
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3331
-
3332
-		$page = evaluer_fond($f, $contexte, $connect);
3333
-		if ($page === '') {
3334
-			$c = isset($options['compil']) ? $options['compil'] : '';
3335
-			$a = ['fichier' => $f];
3336
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3337
-			erreur_squelette($erreur, $c);
3338
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3339
-			$page = ['texte' => '', 'erreur' => $erreur];
3340
-		}
3341
-
3342
-		$page = pipeline('recuperer_fond', [
3343
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3344
-			'data' => $page
3345
-		]);
3346
-		if (isset($options['ajax']) and $options['ajax']) {
3347
-			if (!function_exists('encoder_contexte_ajax')) {
3348
-				include_spip('inc/filtres');
3349
-			}
3350
-			$page['texte'] = encoder_contexte_ajax(
3351
-				array_merge(
3352
-					$contexte,
3353
-					['fond' => $f],
3354
-					($connect ? ['connect' => $connect] : [])
3355
-				),
3356
-				'',
3357
-				$page['texte'],
3358
-				$options['ajax']
3359
-			);
3360
-		}
3361
-
3362
-		if (isset($options['raw']) and $options['raw']) {
3363
-			$pages[] = $page;
3364
-		} else {
3365
-			$texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3366
-		}
3367
-
3368
-		// contamination de la session appelante, pour les inclusions statiques
3369
-		if (isset($page['invalideurs']['session'])) {
3370
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3371
-		}
3372
-	}
3373
-
3374
-	// restaurer le sessionnement du contexte appelant,
3375
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3376
-	if (isset($cache_utilise_session_appelant)) {
3377
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3378
-	}
3379
-
3380
-	$GLOBALS['_INC_PUBLIC']--;
3381
-
3382
-	if ($lang_select) {
3383
-		lang_select();
3384
-	}
3385
-	if (isset($options['raw']) and $options['raw']) {
3386
-		return is_array($fond) ? $pages : reset($pages);
3387
-	} else {
3388
-		return $options['trim'] ? ltrim($texte) : $texte;
3389
-	}
3287
+    if (!function_exists('evaluer_fond')) {
3288
+        include_spip('public/assembler');
3289
+    }
3290
+    // assurer la compat avec l'ancienne syntaxe
3291
+    // (trim etait le 3eme argument, par defaut a true)
3292
+    if (!is_array($options)) {
3293
+        $options = ['trim' => $options];
3294
+    }
3295
+    if (!isset($options['trim'])) {
3296
+        $options['trim'] = true;
3297
+    }
3298
+
3299
+    if (isset($contexte['connect'])) {
3300
+        $connect = $contexte['connect'];
3301
+        unset($contexte['connect']);
3302
+    }
3303
+
3304
+    $texte = '';
3305
+    $pages = [];
3306
+    $lang_select = '';
3307
+    if (!isset($options['etoile']) or !$options['etoile']) {
3308
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3309
+        if (!isset($contexte['lang'])) {
3310
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3311
+        }
3312
+
3313
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3314
+            $lang_select = lang_select($contexte['lang']);
3315
+        }
3316
+    }
3317
+
3318
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3319
+        $GLOBALS['_INC_PUBLIC'] = 0;
3320
+    }
3321
+
3322
+    $GLOBALS['_INC_PUBLIC']++;
3323
+
3324
+    // fix #4235
3325
+    $cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3326
+
3327
+
3328
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3329
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3330
+
3331
+        $page = evaluer_fond($f, $contexte, $connect);
3332
+        if ($page === '') {
3333
+            $c = isset($options['compil']) ? $options['compil'] : '';
3334
+            $a = ['fichier' => $f];
3335
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3336
+            erreur_squelette($erreur, $c);
3337
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3338
+            $page = ['texte' => '', 'erreur' => $erreur];
3339
+        }
3340
+
3341
+        $page = pipeline('recuperer_fond', [
3342
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3343
+            'data' => $page
3344
+        ]);
3345
+        if (isset($options['ajax']) and $options['ajax']) {
3346
+            if (!function_exists('encoder_contexte_ajax')) {
3347
+                include_spip('inc/filtres');
3348
+            }
3349
+            $page['texte'] = encoder_contexte_ajax(
3350
+                array_merge(
3351
+                    $contexte,
3352
+                    ['fond' => $f],
3353
+                    ($connect ? ['connect' => $connect] : [])
3354
+                ),
3355
+                '',
3356
+                $page['texte'],
3357
+                $options['ajax']
3358
+            );
3359
+        }
3360
+
3361
+        if (isset($options['raw']) and $options['raw']) {
3362
+            $pages[] = $page;
3363
+        } else {
3364
+            $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3365
+        }
3366
+
3367
+        // contamination de la session appelante, pour les inclusions statiques
3368
+        if (isset($page['invalideurs']['session'])) {
3369
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3370
+        }
3371
+    }
3372
+
3373
+    // restaurer le sessionnement du contexte appelant,
3374
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3375
+    if (isset($cache_utilise_session_appelant)) {
3376
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3377
+    }
3378
+
3379
+    $GLOBALS['_INC_PUBLIC']--;
3380
+
3381
+    if ($lang_select) {
3382
+        lang_select();
3383
+    }
3384
+    if (isset($options['raw']) and $options['raw']) {
3385
+        return is_array($fond) ? $pages : reset($pages);
3386
+    } else {
3387
+        return $options['trim'] ? ltrim($texte) : $texte;
3388
+    }
3390 3389
 }
3391 3390
 
3392 3391
 /**
@@ -3396,7 +3395,7 @@  discard block
 block discarded – undo
3396 3395
  * @return string
3397 3396
  */
3398 3397
 function trouve_modele($nom) {
3399
-	return trouver_fond($nom, 'modeles/');
3398
+    return trouver_fond($nom, 'modeles/');
3400 3399
 }
3401 3400
 
3402 3401
 /**
@@ -3412,21 +3411,21 @@  discard block
 block discarded – undo
3412 3411
  * @return array|string
3413 3412
  */
3414 3413
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3415
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3416
-	if (!$pathinfo) {
3417
-		return $f;
3418
-	}
3419
-	// renvoyer un tableau detaille si $pathinfo==true
3420
-	$p = pathinfo($f);
3421
-	if (!isset($p['extension']) or !$p['extension']) {
3422
-		$p['extension'] = _EXTENSION_SQUELETTES;
3423
-	}
3424
-	if (!isset($p['extension']) or !$p['filename']) {
3425
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3426
-	}
3427
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3414
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3415
+    if (!$pathinfo) {
3416
+        return $f;
3417
+    }
3418
+    // renvoyer un tableau detaille si $pathinfo==true
3419
+    $p = pathinfo($f);
3420
+    if (!isset($p['extension']) or !$p['extension']) {
3421
+        $p['extension'] = _EXTENSION_SQUELETTES;
3422
+    }
3423
+    if (!isset($p['extension']) or !$p['filename']) {
3424
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3425
+    }
3426
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3428 3427
 
3429
-	return $p;
3428
+    return $p;
3430 3429
 }
3431 3430
 
3432 3431
 /**
@@ -3446,21 +3445,21 @@  discard block
 block discarded – undo
3446 3445
  *     Nom de l'exec, sinon chaîne vide.
3447 3446
  **/
3448 3447
 function tester_url_ecrire($nom) {
3449
-	static $exec = [];
3450
-	if (isset($exec[$nom])) {
3451
-		return $exec[$nom];
3452
-	}
3453
-	// tester si c'est une page en squelette
3454
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3455
-		return $exec[$nom] = 'fond';
3456
-	} // echafaudage d'un fond !
3457
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3458
-		return $exec[$nom] = 'fond';
3459
-	}
3460
-	// attention, il ne faut pas inclure l'exec ici
3461
-	// car sinon #URL_ECRIRE provoque des inclusions
3462
-	// et des define intrusifs potentiels
3463
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3448
+    static $exec = [];
3449
+    if (isset($exec[$nom])) {
3450
+        return $exec[$nom];
3451
+    }
3452
+    // tester si c'est une page en squelette
3453
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3454
+        return $exec[$nom] = 'fond';
3455
+    } // echafaudage d'un fond !
3456
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3457
+        return $exec[$nom] = 'fond';
3458
+    }
3459
+    // attention, il ne faut pas inclure l'exec ici
3460
+    // car sinon #URL_ECRIRE provoque des inclusions
3461
+    // et des define intrusifs potentiels
3462
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3464 3463
 }
3465 3464
 
3466 3465
 /**
@@ -3470,8 +3469,8 @@  discard block
 block discarded – undo
3470 3469
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3471 3470
  **/
3472 3471
 function html5_permis() {
3473
-	return (!defined('_VERSION_HTML')
3474
-		or _VERSION_HTML !== 'html4');
3472
+    return (!defined('_VERSION_HTML')
3473
+        or _VERSION_HTML !== 'html4');
3475 3474
 }
3476 3475
 
3477 3476
 /**
@@ -3481,30 +3480,30 @@  discard block
 block discarded – undo
3481 3480
  * @return array
3482 3481
  */
3483 3482
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3484
-	$formats = null;
3485
-	if (!is_null($gd)) {
3486
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3487
-		if (isset($GLOBALS['meta'][$config])) {
3488
-			$formats = $GLOBALS['meta'][$config];
3489
-			$formats = explode(',', $formats);
3490
-			$formats = array_filter($formats);
3491
-			$formats = array_map('trim', $formats);
3492
-		}
3493
-	}
3494
-	if (is_null($formats)) {
3495
-		include_spip('inc/filtres_images_lib_mini');
3496
-		$formats = _image_extensions_acceptees_en_entree();
3497
-	}
3498
-
3499
-	if ($svg_allowed) {
3500
-		if (!in_array('svg', $formats)) {
3501
-			$formats[] = 'svg';
3502
-		}
3503
-	}
3504
-	else {
3505
-		$formats = array_diff($formats, ['svg']);
3506
-	}
3507
-	return $formats;
3483
+    $formats = null;
3484
+    if (!is_null($gd)) {
3485
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3486
+        if (isset($GLOBALS['meta'][$config])) {
3487
+            $formats = $GLOBALS['meta'][$config];
3488
+            $formats = explode(',', $formats);
3489
+            $formats = array_filter($formats);
3490
+            $formats = array_map('trim', $formats);
3491
+        }
3492
+    }
3493
+    if (is_null($formats)) {
3494
+        include_spip('inc/filtres_images_lib_mini');
3495
+        $formats = _image_extensions_acceptees_en_entree();
3496
+    }
3497
+
3498
+    if ($svg_allowed) {
3499
+        if (!in_array('svg', $formats)) {
3500
+            $formats[] = 'svg';
3501
+        }
3502
+    }
3503
+    else {
3504
+        $formats = array_diff($formats, ['svg']);
3505
+    }
3506
+    return $formats;
3508 3507
 }
3509 3508
 
3510 3509
 /**
@@ -3513,20 +3512,20 @@  discard block
 block discarded – undo
3513 3512
  * @return array|bool
3514 3513
  */
3515 3514
 function spip_getimagesize($fichier) {
3516
-	if (!$imagesize = @getimagesize($fichier)) {
3517
-		include_spip('inc/svg');
3518
-		if ($attrs = svg_lire_attributs($fichier)) {
3519
-			list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3520
-			$imagesize = [
3521
-				$width,
3522
-				$height,
3523
-				IMAGETYPE_SVG,
3524
-				"width=\"{$width}\" height=\"{$height}\"",
3525
-				'mime' => 'image/svg+xml'
3526
-			];
3527
-		}
3528
-	}
3529
-	return $imagesize;
3515
+    if (!$imagesize = @getimagesize($fichier)) {
3516
+        include_spip('inc/svg');
3517
+        if ($attrs = svg_lire_attributs($fichier)) {
3518
+            list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3519
+            $imagesize = [
3520
+                $width,
3521
+                $height,
3522
+                IMAGETYPE_SVG,
3523
+                "width=\"{$width}\" height=\"{$height}\"",
3524
+                'mime' => 'image/svg+xml'
3525
+            ];
3526
+        }
3527
+    }
3528
+    return $imagesize;
3530 3529
 }
3531 3530
 
3532 3531
 /**
@@ -3540,19 +3539,19 @@  discard block
 block discarded – undo
3540 3539
  * @param string $statut
3541 3540
  */
3542 3541
 function avertir_auteurs($nom, $message, $statut = '') {
3543
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3544
-	if (
3545
-		!$alertes
3546
-		or !is_array($alertes = unserialize($alertes))
3547
-	) {
3548
-		$alertes = [];
3549
-	}
3542
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3543
+    if (
3544
+        !$alertes
3545
+        or !is_array($alertes = unserialize($alertes))
3546
+    ) {
3547
+        $alertes = [];
3548
+    }
3550 3549
 
3551
-	if (!isset($alertes[$statut])) {
3552
-		$alertes[$statut] = [];
3553
-	}
3554
-	$alertes[$statut][$nom] = $message;
3555
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3550
+    if (!isset($alertes[$statut])) {
3551
+        $alertes[$statut] = [];
3552
+    }
3553
+    $alertes[$statut][$nom] = $message;
3554
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3556 3555
 }
3557 3556
 
3558 3557
 /**
@@ -3566,10 +3565,10 @@  discard block
 block discarded – undo
3566 3565
  * @return string|string[]
3567 3566
  */
3568 3567
 function spip_sanitize_classname($classes) {
3569
-	if (is_array($classes)) {
3570
-		return array_map('spip_sanitize_classname', $classes);
3571
-	}
3572
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3568
+    if (is_array($classes)) {
3569
+        return array_map('spip_sanitize_classname', $classes);
3570
+    }
3571
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3573 3572
 }
3574 3573
 
3575 3574
 
@@ -3594,32 +3593,32 @@  discard block
 block discarded – undo
3594 3593
  *    Avec operateur : bool.
3595 3594
  **/
3596 3595
 function spip_version_compare($v1, $v2, $op = null) {
3597
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3598
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3599
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3600
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3601
-
3602
-	$v1 = explode('.', $v1);
3603
-	$v2 = explode('.', $v2);
3604
-	// $v1 est toujours une version, donc sans etoile
3605
-	while (count($v1) < count($v2)) {
3606
-		$v1[] = '0';
3607
-	}
3608
-
3609
-	// $v2 peut etre une borne, donc accepte l'etoile
3610
-	$etoile = false;
3611
-	foreach ($v1 as $k => $v) {
3612
-		if (!isset($v2[$k])) {
3613
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3614
-		} else {
3615
-			if ($v2[$k] == '*') {
3616
-				$etoile = true;
3617
-				$v2[$k] = $v;
3618
-			}
3619
-		}
3620
-	}
3621
-	$v1 = implode('.', $v1);
3622
-	$v2 = implode('.', $v2);
3623
-
3624
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3596
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3597
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3598
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3599
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3600
+
3601
+    $v1 = explode('.', $v1);
3602
+    $v2 = explode('.', $v2);
3603
+    // $v1 est toujours une version, donc sans etoile
3604
+    while (count($v1) < count($v2)) {
3605
+        $v1[] = '0';
3606
+    }
3607
+
3608
+    // $v2 peut etre une borne, donc accepte l'etoile
3609
+    $etoile = false;
3610
+    foreach ($v1 as $k => $v) {
3611
+        if (!isset($v2[$k])) {
3612
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3613
+        } else {
3614
+            if ($v2[$k] == '*') {
3615
+                $etoile = true;
3616
+                $v2[$k] = $v;
3617
+            }
3618
+        }
3619
+    }
3620
+    $v1 = implode('.', $v1);
3621
+    $v2 = implode('.', $v2);
3622
+
3623
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3625 3624
 }
Please login to merge, or discard this patch.
ecrire/inc/nfslock.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  **/
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/acces');
@@ -101,93 +101,93 @@  discard block
 block discarded – undo
101 101
  * @return int|bool Timestamp du verrou, false si erreur
102 102
  */
103 103
 function spip_nfslock($fichier, $max_age = 0) {
104
-	$tries = 0;
104
+    $tries = 0;
105 105
 
106
-	if (!$max_age) {
107
-		$max_age = _DEFAULT_LOCKTIME;
108
-	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
106
+    if (!$max_age) {
107
+        $max_age = _DEFAULT_LOCKTIME;
108
+    }
109
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112
-	/*
112
+    /*
113 113
 	 * 1. create a tmp file with a psuedo random file name. we also make
114 114
 	 *    tpath which is a buffer to store the full pathname of the tmp file.
115 115
 	 */
116 116
 
117
-	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
119
-	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
-	if (!$tmpfd) {  /* open failed */
121
-		@fclose($tmpfd);
122
-		spip_unlink($tpath);
117
+    $id = creer_uniqid();
118
+    $tpath = _DIR_TMP . "slock.$id";
119
+    $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
+    if (!$tmpfd) {  /* open failed */
121
+        @fclose($tmpfd);
122
+        spip_unlink($tpath);
123 123
 
124
-		return false; //NFSL_SYSF
125
-	}
124
+        return false; //NFSL_SYSF
125
+    }
126 126
 
127
-	/*
127
+    /*
128 128
 	 * 2. make fullpath, a buffer for the full pathname of the lock file.
129 129
 	 *    then start looping trying to lock it
130 130
 	 */
131 131
 
132
-	while ($tries < 10) {
133
-		/*
132
+    while ($tries < 10) {
133
+        /*
134 134
 		 * 3. link tmp file to lock file.  if it goes, we win and we clean
135 135
 		 *    up and return the st_ctime of the lock file.
136 136
 		 */
137 137
 
138
-		if (link($tpath, $lock_file) == 1) {
139
-			spip_unlink($tpath); /* got it! */
140
-			@fclose($tmpfd);
141
-			if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
-				spip_unlink($lock_file);
138
+        if (link($tpath, $lock_file) == 1) {
139
+            spip_unlink($tpath); /* got it! */
140
+            @fclose($tmpfd);
141
+            if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
+                spip_unlink($lock_file);
143 143
 
144
-				return false; // (NFSL_SYSF);
145
-			}
144
+                return false; // (NFSL_SYSF);
145
+            }
146 146
 
147
-			return ($our_tmp['ctime']);
148
-		}
147
+            return ($our_tmp['ctime']);
148
+        }
149 149
 
150
-		/*
150
+        /*
151 151
 		 * 4. the lock failed.  check for a stale lock file, being mindful
152 152
 		 *    of NFS and the fact the time is set from the NFS server.  we
153 153
 		 *    do a write on the tmp file to update its time to the server's
154 154
 		 *    idea of "now."
155 155
 		 */
156 156
 
157
-		$old_stat = lstat($lock_file);
158
-		if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
-			break;
160
-		} /* something bogus is going on */
157
+        $old_stat = lstat($lock_file);
158
+        if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
+            break;
160
+        } /* something bogus is going on */
161 161
 
162 162
 
163
-		if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
-			spip_unlink($lock_file); /* break the stale lock */
165
-			$tries++;
166
-			/* It is CRITICAL that we sleep after breaking
163
+        if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
+            spip_unlink($lock_file); /* break the stale lock */
165
+            $tries++;
166
+            /* It is CRITICAL that we sleep after breaking
167 167
 			 * the lock. Otherwise, we could race with
168 168
 			 * another process and unlink it's newly-
169 169
 			 * created file.
170 170
 			 */
171
-			sleep(1 + rand(0, 4));
172
-			continue;
173
-		}
171
+            sleep(1 + rand(0, 4));
172
+            continue;
173
+        }
174 174
 
175
-		/*
175
+        /*
176 176
 		 * 5. try again
177 177
 		 */
178 178
 
179
-		$tries++;
180
-		sleep(1 + rand(0, 4));
181
-	}
179
+        $tries++;
180
+        sleep(1 + rand(0, 4));
181
+    }
182 182
 
183
-	/*
183
+    /*
184 184
 	 * 6. give up, failure.
185 185
 	 */
186 186
 
187
-	spip_unlink($tpath);
188
-	@fclose($tmpfd);
187
+    spip_unlink($tpath);
188
+    @fclose($tmpfd);
189 189
 
190
-	return false; //(NFSL_LOCKED);
190
+    return false; //(NFSL_LOCKED);
191 191
 }
192 192
 
193 193
 /**
@@ -231,75 +231,75 @@  discard block
 block discarded – undo
231 231
  * return bool true si déverrouillé, false sinon
232 232
  */
233 233
 function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) {
234
-	$id = creer_uniqid();
235
-	if (!$max_age) {
236
-		$max_age = _DEFAULT_LOCKTIME;
237
-	}
234
+    $id = creer_uniqid();
235
+    if (!$max_age) {
236
+        $max_age = _DEFAULT_LOCKTIME;
237
+    }
238 238
 
239
-	/*
239
+    /*
240 240
 	 * 1. Build a temp file and stat that to get an idea of what the server
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
245
-	$tmpfd = @fopen($tpath, 'w');
246
-	if (
247
-		(!$tmpfd)
248
-		or (@fputs($tmpfd, 'zz', 2) != 2)
249
-		or !($our_tmp = fstat($tmpfd))
250
-	) {
251
-		/* The open failed, or we can't write the file, or we can't stat it */
252
-		@fclose($tmpfd);
253
-		spip_unlink($tpath);
244
+    $tpath = _DIR_TMP . "stime.$id";
245
+    $tmpfd = @fopen($tpath, 'w');
246
+    if (
247
+        (!$tmpfd)
248
+        or (@fputs($tmpfd, 'zz', 2) != 2)
249
+        or !($our_tmp = fstat($tmpfd))
250
+    ) {
251
+        /* The open failed, or we can't write the file, or we can't stat it */
252
+        @fclose($tmpfd);
253
+        spip_unlink($tpath);
254 254
 
255
-		return false; //(NFSL_SYSF);
256
-	}
255
+        return false; //(NFSL_SYSF);
256
+    }
257 257
 
258
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
259
-	spip_unlink($tpath);
258
+    @fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
259
+    spip_unlink($tpath);
260 260
 
261
-	/*
261
+    /*
262 262
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
263 263
 	 */
264 264
 
265
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
265
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
266 266
 
267
-	/*
267
+    /*
268 268
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
269 269
 	 *    lock has expired, sleep the usual random interval before returning.
270 270
 	 *    If we didn't sleep, there could be a race if the caller immediately
271 271
 	 *    tries to relock the file.
272 272
 	 */
273 273
 
274
-	if (
275
-		($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
276
-		&& ($old_stat['ctime'] == $birth)
277
-	) {  /* hasn't been modified since birth */
278
-		if (!$test) {
279
-			spip_unlink($lock_file);
280
-		}      /* so the lock is ours to remove */
281
-		if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
282
-			if (!$test) {
283
-				return false;
284
-			} //(NFSL_LOST);
285
-			sleep(1 + (random(0, 4)));    /* so sleep a bit */
286
-		}
287
-
288
-		return true;//(NFSL_OK);			/* success */
289
-	}
290
-
291
-	/*
274
+    if (
275
+        ($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
276
+        && ($old_stat['ctime'] == $birth)
277
+    ) {  /* hasn't been modified since birth */
278
+        if (!$test) {
279
+            spip_unlink($lock_file);
280
+        }      /* so the lock is ours to remove */
281
+        if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
282
+            if (!$test) {
283
+                return false;
284
+            } //(NFSL_LOST);
285
+            sleep(1 + (random(0, 4)));    /* so sleep a bit */
286
+        }
287
+
288
+        return true;//(NFSL_OK);			/* success */
289
+    }
290
+
291
+    /*
292 292
 	 * 4. Either ctime has been modified, or the entire lock file is missing.
293 293
 	 *    If the lock should still be ours, based on the ctime of the temp
294 294
 	 *    file, return with NFSL_STOLEN. If not, then our lock is expired and
295 295
 	 *    someone else has grabbed the file, so return NFSL_LOST.
296 296
 	 */
297 297
 
298
-	if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
299
-		return false;
300
-	} //(NFSL_STOLEN);
298
+    if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
299
+        return false;
300
+    } //(NFSL_STOLEN);
301 301
 
302
-	return false; //(NFSL_LOST);	/* The lock must have expired first. */
302
+    return false; //(NFSL_LOST);	/* The lock must have expired first. */
303 303
 }
304 304
 
305 305
 
@@ -323,5 +323,5 @@  discard block
 block discarded – undo
323 323
  * return bool true si déverrouillé, false sinon
324 324
  */
325 325
 function spip_nfslock_test($fichier, $birth, $max_age = 0) {
326
-	return spip_nfsunlock($fichier, $birth, $max_age, true);
326
+    return spip_nfsunlock($fichier, $birth, $max_age, true);
327 327
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	if (!$max_age) {
107 107
 		$max_age = _DEFAULT_LOCKTIME;
108 108
 	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
109
+	$lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112 112
 	/*
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 
117 117
 	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
118
+	$tpath = _DIR_TMP."slock.$id";
119 119
 	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120 120
 	if (!$tmpfd) {  /* open failed */
121 121
 		@fclose($tmpfd);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
244
+	$tpath = _DIR_TMP."stime.$id";
245 245
 	$tmpfd = @fopen($tpath, 'w');
246 246
 	if (
247 247
 		(!$tmpfd)
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 		return false; //(NFSL_SYSF);
256 256
 	}
257 257
 
258
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
258
+	@fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */
259 259
 	spip_unlink($tpath);
260 260
 
261 261
 	/*
262 262
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
263 263
 	 */
264 264
 
265
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
265
+	$lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8);
266 266
 
267 267
 	/*
268 268
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 			if (!$test) {
283 283
 				return false;
284 284
 			} //(NFSL_LOST);
285
-			sleep(1 + (random(0, 4)));    /* so sleep a bit */
285
+			sleep(1 + (random(0, 4))); /* so sleep a bit */
286 286
 		}
287 287
 
288
-		return true;//(NFSL_OK);			/* success */
288
+		return true; //(NFSL_OK);			/* success */
289 289
 	}
290 290
 
291 291
 	/*
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@  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
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
25
-	/**
26
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques.
27
-	 * Au delà, on bascule sur un sélecteur ajax.
28
-	 * mettre 100000 pour desactiver ajax
29
-	 */
30
-	define('_SPIP_SELECT_RUBRIQUES', 20);
25
+    /**
26
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques.
27
+     * Au delà, on bascule sur un sélecteur ajax.
28
+     * mettre 100000 pour desactiver ajax
29
+     */
30
+    define('_SPIP_SELECT_RUBRIQUES', 20);
31 31
 }
32 32
 
33 33
 /**
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
  *     Code HTML du sélecteur
56 56
  **/
57 57
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
58
-	if (sql_countsel('spip_rubriques') < 1) {
59
-		return '';
60
-	}
61
-
62
-	// Mode sans Ajax :
63
-	// - soit parce que le cookie ajax n'est pas la
64
-	// - soit parce qu'il y a peu de rubriques
65
-	if (
66
-		_SPIP_AJAX < 1
67
-		or $type == 'breve'
68
-		or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
69
-	) {
70
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
71
-	} else {
72
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
73
-	}
58
+    if (sql_countsel('spip_rubriques') < 1) {
59
+        return '';
60
+    }
61
+
62
+    // Mode sans Ajax :
63
+    // - soit parce que le cookie ajax n'est pas la
64
+    // - soit parce qu'il y a peu de rubriques
65
+    if (
66
+        _SPIP_AJAX < 1
67
+        or $type == 'breve'
68
+        or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
69
+    ) {
70
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
71
+    } else {
72
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
73
+    }
74 74
 }
75 75
 
76 76
 // compatibilite pour extensions qui utilisaient l'ancien nom
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
  **/
88 88
 function style_menu_rubriques($i) {
89 89
 
90
-	$espace = '';
91
-	$style = '';
92
-	for ($count = 1; $count <= $i; $count++) {
93
-		$espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
94
-	}
95
-	if ($i == 1) {
96
-		$espace = '';
97
-	}
98
-	$class = "niveau_$i";
99
-
100
-	return [$class, $style, $espace];
90
+    $espace = '';
91
+    $style = '';
92
+    for ($count = 1; $count <= $i; $count++) {
93
+        $espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
94
+    }
95
+    if ($i == 1) {
96
+        $espace = '';
97
+    }
98
+    $class = "niveau_$i";
99
+
100
+    return [$class, $style, $espace];
101 101
 }
102 102
 
103 103
 /**
@@ -121,60 +121,60 @@  discard block
 block discarded – undo
121 121
  *     Code HTML du sélecteur
122 122
  **/
123 123
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
124
-	static $decalage_secteur;
125
-
126
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
-	if (
128
-		$exclus > 0
129
-		and $root == $exclus
130
-	) {
131
-		return '';
132
-	}
133
-
134
-	// en fonction du niveau faire un affichage plus ou moins kikoo
135
-
136
-	// selected ?
137
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
138
-
139
-	// le style en fonction de la profondeur
140
-	list($class, $style, $espace) = style_menu_rubriques($niv);
141
-
142
-	$class .= ' selec_rub';
143
-
144
-	// creer l'<option> pour la rubrique $root
145
-
146
-	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147
-	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
-			. $data[$root]
149
-			. '</option>' . "\n";
150
-	} else {
151
-		$r = '';
152
-	}
153
-
154
-	// et le sous-menu pour ses enfants
155
-	$sous = '';
156
-	if (isset($enfants[$root])) {
157
-		foreach ($enfants[$root] as $sousrub) {
158
-			$sous .= sous_menu_rubriques(
159
-				$id_rubrique,
160
-				$sousrub,
161
-				$niv + 1,
162
-				$data,
163
-				$enfants,
164
-				$exclus,
165
-				$restreint,
166
-				$type
167
-			);
168
-		}
169
-	}
170
-
171
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
172
-	if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
173
-		return $sous;
174
-	}
175
-
176
-	// et voila le travail
177
-	return $r . $sous;
124
+    static $decalage_secteur;
125
+
126
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
+    if (
128
+        $exclus > 0
129
+        and $root == $exclus
130
+    ) {
131
+        return '';
132
+    }
133
+
134
+    // en fonction du niveau faire un affichage plus ou moins kikoo
135
+
136
+    // selected ?
137
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
138
+
139
+    // le style en fonction de la profondeur
140
+    list($class, $style, $espace) = style_menu_rubriques($niv);
141
+
142
+    $class .= ' selec_rub';
143
+
144
+    // creer l'<option> pour la rubrique $root
145
+
146
+    if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147
+    $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
+            . $data[$root]
149
+            . '</option>' . "\n";
150
+    } else {
151
+        $r = '';
152
+    }
153
+
154
+    // et le sous-menu pour ses enfants
155
+    $sous = '';
156
+    if (isset($enfants[$root])) {
157
+        foreach ($enfants[$root] as $sousrub) {
158
+            $sous .= sous_menu_rubriques(
159
+                $id_rubrique,
160
+                $sousrub,
161
+                $niv + 1,
162
+                $data,
163
+                $enfants,
164
+                $exclus,
165
+                $restreint,
166
+                $type
167
+            );
168
+        }
169
+    }
170
+
171
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
172
+    if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
173
+        return $sous;
174
+    }
175
+
176
+    // et voila le travail
177
+    return $r . $sous;
178 178
 }
179 179
 
180 180
 /**
@@ -195,74 +195,74 @@  discard block
 block discarded – undo
195 195
  *     Code HTML du sélecteur
196 196
  **/
197 197
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
198
-	$data = [];
199
-	if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
200
-		$data[0] = _T('info_racine_site');
201
-	}
202
-	# premier choix = neant
203
-	# si auteur (rubriques restreintes)
204
-	# ou si creation avec id_rubrique=0
205
-	elseif ($type == 'auteur' or !$id_rubrique) {
206
-		$data[0] = '&nbsp;';
207
-	}
208
-
209
-	//
210
-	// creer une structure contenant toute l'arborescence
211
-	//
212
-
213
-	include_spip('base/abstract_sql');
214
-	$q = sql_select(
215
-		'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
216
-		'spip_rubriques',
217
-		($type == 'breve' ? ' id_parent=0 ' : ''),
218
-		'',
219
-		'0+titre,titre'
220
-	);
221
-	while ($r = sql_fetch($q)) {
222
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
223
-			// titre largeur maxi a 50
224
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
225
-			if (
226
-				$GLOBALS['meta']['multi_rubriques'] == 'oui'
227
-				and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
228
-			) {
229
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
230
-			}
231
-			$data[$r['id_rubrique']] = $titre;
232
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
233
-			if ($id_rubrique == $r['id_rubrique']) {
234
-				$id_parent = $r['id_parent'];
235
-			}
236
-		}
237
-	}
238
-
239
-	// si une seule rubrique comme choix possible,
240
-	// inutile de mettre le selecteur sur un choix vide par defaut
241
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
242
-	if (
243
-		count($data) == 2
244
-		and isset($data[0])
245
-		and !in_array($type, ['auteur', 'rubrique'])
246
-		and !$id_rubrique
247
-	) {
248
-		unset($data[0]);
249
-	}
250
-
251
-
252
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
253
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
254
-
255
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
256
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
257
-	} else {
258
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
259
-	}
260
-
261
-	# message pour neuneus (a supprimer ?)
198
+    $data = [];
199
+    if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
200
+        $data[0] = _T('info_racine_site');
201
+    }
202
+    # premier choix = neant
203
+    # si auteur (rubriques restreintes)
204
+    # ou si creation avec id_rubrique=0
205
+    elseif ($type == 'auteur' or !$id_rubrique) {
206
+        $data[0] = '&nbsp;';
207
+    }
208
+
209
+    //
210
+    // creer une structure contenant toute l'arborescence
211
+    //
212
+
213
+    include_spip('base/abstract_sql');
214
+    $q = sql_select(
215
+        'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
216
+        'spip_rubriques',
217
+        ($type == 'breve' ? ' id_parent=0 ' : ''),
218
+        '',
219
+        '0+titre,titre'
220
+    );
221
+    while ($r = sql_fetch($q)) {
222
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
223
+            // titre largeur maxi a 50
224
+            $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
225
+            if (
226
+                $GLOBALS['meta']['multi_rubriques'] == 'oui'
227
+                and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
228
+            ) {
229
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
230
+            }
231
+            $data[$r['id_rubrique']] = $titre;
232
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
233
+            if ($id_rubrique == $r['id_rubrique']) {
234
+                $id_parent = $r['id_parent'];
235
+            }
236
+        }
237
+    }
238
+
239
+    // si une seule rubrique comme choix possible,
240
+    // inutile de mettre le selecteur sur un choix vide par defaut
241
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
242
+    if (
243
+        count($data) == 2
244
+        and isset($data[0])
245
+        and !in_array($type, ['auteur', 'rubrique'])
246
+        and !$id_rubrique
247
+    ) {
248
+        unset($data[0]);
249
+    }
250
+
251
+
252
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
253
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
254
+
255
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
256
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
257
+    } else {
258
+        $r = '<select' . $att . " size='1'>\n$opt</select>\n";
259
+    }
260
+
261
+    # message pour neuneus (a supprimer ?)
262 262
 #	if ($type != 'auteur' AND $type != 'breve')
263 263
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
264 264
 
265
-	return $r;
265
+    return $r;
266 266
 }
267 267
 
268 268
 /**
@@ -296,26 +296,26 @@  discard block
 block discarded – undo
296 296
  */
297 297
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
298 298
 
299
-	if ($id_rubrique) {
300
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
301
-	} else {
302
-		if ($type == 'auteur') {
303
-			$titre = '&nbsp;';
304
-		} else {
305
-			$titre = _T('info_racine_site');
306
-		}
307
-	}
299
+    if ($id_rubrique) {
300
+        $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
301
+    } else {
302
+        if ($type == 'auteur') {
303
+            $titre = '&nbsp;';
304
+        } else {
305
+            $titre = _T('info_racine_site');
306
+        }
307
+    }
308 308
 
309
-	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
310
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
309
+    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
310
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
311 311
 
312
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
313
-		. (!$idem ? '' : "&exclus=$idem")
314
-		. ($restreint ? '' : '&racine=oui')
315
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
312
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
313
+        . (!$idem ? '' : "&exclus=$idem")
314
+        . ($restreint ? '' : '&racine=oui')
315
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
316 316
 
317 317
 
318
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
318
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
319 319
 }
320 320
 
321 321
 /**
@@ -345,30 +345,30 @@  discard block
 block discarded – undo
345 345
  *     Code HTML du sélecteur de rubrique AJAX
346 346
  **/
347 347
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
348
-	$icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
349
-	// si icone de recherche on embed le svg
350
-	$balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
351
-	$img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur')));
352
-
353
-	return
354
-		"<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
355
-		. $js
356
-		. " jQuery(this).toggleClass('toggled'); "
357
-		. "return charger_node_url_si_vide('"
358
-		. $url
359
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
360
-		. $img_icone
361
-		. "</a><img src='"
362
-		. chemin_image('loader.svg')
363
-		. "' class='loader' id='img_"
364
-		. $idom
365
-		. "'\nstyle='visibility: hidden;' alt='*' />"
366
-		. "<input id='titreparent' name='titreparent' class='text'"
367
-		. $init
368
-		. ' />'
369
-		. "<input type='hidden' id='$name' name='$name' value='"
370
-		. $id
371
-		. "' /><div class='nettoyeur'></div></div><div id='"
372
-		. $idom
373
-		. "'\nstyle='display: none;'></div>";
348
+    $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
349
+    // si icone de recherche on embed le svg
350
+    $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
351
+    $img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur')));
352
+
353
+    return
354
+        "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
355
+        . $js
356
+        . " jQuery(this).toggleClass('toggled'); "
357
+        . "return charger_node_url_si_vide('"
358
+        . $url
359
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
360
+        . $img_icone
361
+        . "</a><img src='"
362
+        . chemin_image('loader.svg')
363
+        . "' class='loader' id='img_"
364
+        . $idom
365
+        . "'\nstyle='visibility: hidden;' alt='*' />"
366
+        . "<input id='titreparent' name='titreparent' class='text'"
367
+        . $init
368
+        . ' />'
369
+        . "<input type='hidden' id='$name' name='$name' value='"
370
+        . $id
371
+        . "' /><div class='nettoyeur'></div></div><div id='"
372
+        . $idom
373
+        . "'\nstyle='display: none;'></div>";
374 374
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147 147
 	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148 148
 			. $data[$root]
149
-			. '</option>' . "\n";
149
+			. '</option>'."\n";
150 150
 	} else {
151 151
 		$r = '';
152 152
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	// et voila le travail
177
-	return $r . $sous;
177
+	return $r.$sous;
178 178
 }
179 179
 
180 180
 /**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 	while ($r = sql_fetch($q)) {
222 222
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
223 223
 			// titre largeur maxi a 50
224
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
224
+			$titre = couper(supprimer_tags(typo($r['titre'])).' ', 50);
225 225
 			if (
226 226
 				$GLOBALS['meta']['multi_rubriques'] == 'oui'
227 227
 				and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
228 228
 			) {
229
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
229
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
230 230
 			}
231 231
 			$data[$r['id_rubrique']] = $titre;
232 232
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
254 254
 
255 255
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
256
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
256
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
257 257
 	} else {
258
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
258
+		$r = '<select'.$att." size='1'>\n$opt</select>\n";
259 259
 	}
260 260
 
261 261
 	# message pour neuneus (a supprimer ?)
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
298 298
 
299 299
 	if ($id_rubrique) {
300
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
300
+		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique));
301 301
 	} else {
302 302
 		if ($type == 'auteur') {
303 303
 			$titre = '&nbsp;';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	}
308 308
 
309 309
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
310
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
310
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
311 311
 
312 312
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
313 313
 		. (!$idem ? '' : "&exclus=$idem")
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		. " jQuery(this).toggleClass('toggled'); "
357 357
 		. "return charger_node_url_si_vide('"
358 358
 		. $url
359
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
359
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>"
360 360
 		. $img_icone
361 361
 		. "</a><img src='"
362 362
 		. chemin_image('loader.svg')
Please login to merge, or discard this patch.