Completed
Push — master ( 9f5c8b...067bd7 )
by cam
04:23
created
ecrire/inc/install.php 3 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -234,6 +234,9 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
 // https://code.spip.net/@info_etape
237
+/**
238
+ * @param string $titre
239
+ */
237 240
 function info_etape($titre, $complement = '') {
238 241
 	return "<h2>" . $titre . "</h2>\n" .
239 242
 	($complement ? "" . $complement . "\n" : '');
@@ -259,6 +262,11 @@  discard block
 block discarded – undo
259 262
 }
260 263
 
261 264
 // https://code.spip.net/@info_progression_etape
265
+/**
266
+ * @param integer $en_cours
267
+ * @param string $phase
268
+ * @param string $dir
269
+ */
262 270
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263 271
 	//$en_cours = _request('etape')?_request('etape'):"";
264 272
 	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
@@ -315,6 +323,9 @@  discard block
 block discarded – undo
315 323
 
316 324
 
317 325
 // https://code.spip.net/@fieldset
326
+/**
327
+ * @param string $legend
328
+ */
318 329
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319 330
 	return "<fieldset>\n" .
320 331
 	$avant .
@@ -382,6 +393,10 @@  discard block
 block discarded – undo
382 393
 }
383 394
 
384 395
 // https://code.spip.net/@install_connexion_form
396
+/**
397
+ * @param string[] $pass
398
+ * @param integer $etape
399
+ */
385 400
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386 401
 	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387 402
 
@@ -559,6 +574,9 @@  discard block
 block discarded – undo
559 574
 	return array($checked, $bases);
560 575
 }
561 576
 
577
+/**
578
+ * @param string[] $hidden
579
+ */
562 580
 function install_propager($hidden) {
563 581
 	$res = '';
564 582
 	foreach ($hidden as $k) {
Please login to merge, or discard this patch.
Indentation   +354 added lines, -354 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,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. "?" . ">";
46
+    $texte = "<" . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . "?" . ">";
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. "spip_connect_db("
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . "spip_connect_db("
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return array();
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return array();
129 129
 }
130 130
 
131 131
 /**
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = array();
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = array();
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
@@ -164,52 +164,52 @@  discard block
 block discarded – undo
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 // https://code.spip.net/@tester_compatibilite_hebergement
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = array();
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
-	}
173
-
174
-	// Si on n'a pas la bonne version de PHP, c'est la fin
175
-	if ($err) {
176
-		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
-	}
180
-
181
-	// Il faut une base de donnees tout de meme ...
182
-	$serveurs = install_select_serveur();
183
-	if (!$serveurs) {
184
-		$err[] = _T('install_extension_php_obligatoire')
185
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
-	}
189
-
190
-	// et il faut preg
191
-	if (!function_exists('preg_match_all')) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://se.php.net/pcre'>PCRE</a>";
194
-	}
195
-
196
-	// et surtout pas ce mbstring.overload
197
-	if ($a = @ini_get('mbstring.func_overload')) {
198
-		$err[] = _T('install_extension_mbstring')
199
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
-	}
201
-
202
-	if ($err) {
203
-		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
-		foreach ($err as $e) {
206
-			echo "<li><strong>$e</strong></li>\n";
207
-		}
208
-
209
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
210
-		# de forcer malgre tout (pour tester, ou si bug de detection)
211
-		echo "</ul></div>\n";
212
-	}
167
+    $err = array();
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
+    }
173
+
174
+    // Si on n'a pas la bonne version de PHP, c'est la fin
175
+    if ($err) {
176
+        die("<div class='error'>"
177
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
+    }
180
+
181
+    // Il faut une base de donnees tout de meme ...
182
+    $serveurs = install_select_serveur();
183
+    if (!$serveurs) {
184
+        $err[] = _T('install_extension_php_obligatoire')
185
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
+    }
189
+
190
+    // et il faut preg
191
+    if (!function_exists('preg_match_all')) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://se.php.net/pcre'>PCRE</a>";
194
+    }
195
+
196
+    // et surtout pas ce mbstring.overload
197
+    if ($a = @ini_get('mbstring.func_overload')) {
198
+        $err[] = _T('install_extension_mbstring')
199
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
+    }
201
+
202
+    if ($err) {
203
+        echo "<div class='error'>"
204
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+        foreach ($err as $e) {
206
+            echo "<li><strong>$e</strong></li>\n";
207
+        }
208
+
209
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
210
+        # de forcer malgre tout (pour tester, ou si bug de detection)
211
+        echo "</ul></div>\n";
212
+    }
213 213
 }
214 214
 
215 215
 
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
  * @note superflu ??
220 220
  */
221 221
 function login_hebergeur() {
222
-	$base_hebergeur = 'localhost'; # par defaut
222
+    $base_hebergeur = 'localhost'; # par defaut
223 223
 
224
-	// Free
225
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
-		$base_hebergeur = 'sql.free.fr';
227
-		$login_hebergeur = $regs[1];
228
-	} else {
229
-		$login_hebergeur = '';
230
-	}
224
+    // Free
225
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
+        $base_hebergeur = 'sql.free.fr';
227
+        $login_hebergeur = $regs[1];
228
+    } else {
229
+        $login_hebergeur = '';
230
+    }
231 231
 
232
-	return array($base_hebergeur, $login_hebergeur);
232
+    return array($base_hebergeur, $login_hebergeur);
233 233
 }
234 234
 
235 235
 
236 236
 // https://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+    return "<h2>" . $titre . "</h2>\n" .
239
+    ($complement ? "" . $complement . "\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -246,155 +246,155 @@  discard block
 block discarded – undo
246 246
  * @return string Code HTML du bouton
247 247
  **/
248 248
 function bouton_suivant($code = '') {
249
-	if ($code == '') {
250
-		$code = _T('bouton_suivant');
251
-	}
252
-	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
-	$suivant += 1;
255
-
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
258
-	" >>\" /></p>\n";
249
+    if ($code == '') {
250
+        $code = _T('bouton_suivant');
251
+    }
252
+    static $suivant = 0;
253
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
+    $suivant += 1;
255
+
256
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
+    $code .
258
+    " >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // https://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263
-	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
-	$debut = 1;
266
-	$etat = "ok";
267
-	$last = count($liste);
263
+    //$en_cours = _request('etape')?_request('etape'):"";
264
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
+    $debut = 1;
266
+    $etat = "ok";
267
+    $last = count($liste);
268 268
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
269 269
 
270
-	$intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
-	$intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
-	$intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
-	$intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
270
+    $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
+    $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
+    $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
+    $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
274 274
 
275
-	$intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
-	$intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
-	$intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
-	$intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
-	$intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
275
+    $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
+    $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
+    $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
+    $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
+    $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
280 280
 
281 281
 //	$aff_etapes = "<span id='etapes'>";
282 282
 
283
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
-
285
-	foreach ($liste as $etape => $fichier) {
286
-		if ($debut < $last) {
287
-			if ($debut == $en_cours && $erreur) {
288
-				$class = "on erreur";
289
-			} else {
290
-				if ($debut == $en_cours) {
291
-					$class = "on";
292
-				} else {
293
-					if ($debut > $en_cours) {
294
-						$class = "prochains";
295
-					} else {
296
-						$class = "valides";
297
-					}
298
-				}
299
-			}
300
-
301
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
302
-			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
305
-			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
-			$aff_etapes .= "</div></li>";
307
-		}
308
-		$debut++;
309
-	}
310
-	$aff_etapes .= "</ul>";
311
-	$aff_etapes .= "<br class='nettoyeur' />\n";
312
-
313
-	return $aff_etapes;
283
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
+
285
+    foreach ($liste as $etape => $fichier) {
286
+        if ($debut < $last) {
287
+            if ($debut == $en_cours && $erreur) {
288
+                $class = "on erreur";
289
+            } else {
290
+                if ($debut == $en_cours) {
291
+                    $class = "on";
292
+                } else {
293
+                    if ($debut > $en_cours) {
294
+                        $class = "prochains";
295
+                    } else {
296
+                        $class = "valides";
297
+                    }
298
+                }
299
+            }
300
+
301
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
302
+            $aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
+            $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
305
+            $aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
+            $aff_etapes .= "</div></li>";
307
+        }
308
+        $debut++;
309
+    }
310
+    $aff_etapes .= "</ul>";
311
+    $aff_etapes .= "<br class='nettoyeur' />\n";
312
+
313
+    return $aff_etapes;
314 314
 }
315 315
 
316 316
 
317 317
 // https://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
324
-	"</fieldset>\n";
319
+    return "<fieldset>\n" .
320
+    $avant .
321
+    ($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
+    fieldset_champs($champs) .
323
+    $apres .
324
+    "</fieldset>\n";
325 325
 }
326 326
 
327 327
 function fieldset_champs($champs = array()) {
328
-	$fieldset = '';
329
-	foreach ($champs as $nom => $contenu) {
330
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
-		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
334
-			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
336
-					"' id='$nom-$valeur' value='$valeur'"
337
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
-					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
-			}
341
-			$fieldset .= "<br />\n";
342
-		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
-				. " />\n";
348
-		}
349
-	}
350
-
351
-	return $fieldset;
328
+    $fieldset = '';
329
+    foreach ($champs as $nom => $contenu) {
330
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
+        if (isset($contenu['alternatives'])) {
333
+            $fieldset .= $contenu['label'] . "\n";
334
+            foreach ($contenu['alternatives'] as $valeur => $label) {
335
+                $fieldset .= "<input type='radio' name='" . $nom .
336
+                    "' id='$nom-$valeur' value='$valeur'"
337
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
+                    . "/>\n";
339
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
+            }
341
+            $fieldset .= "<br />\n";
342
+        } else {
343
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
+            $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
+                . " />\n";
348
+        }
349
+    }
350
+
351
+    return $fieldset;
352 352
 }
353 353
 
354 354
 function install_select_serveur() {
355
-	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
357
-	$d = opendir($dir);
358
-	if (!$d) {
359
-		return array();
360
-	}
361
-	while (($f = readdir($d)) !== false) {
362
-		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
364
-		) {
365
-			require_once($f);
366
-			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
368
-			if (function_exists($v) and $v()) {
369
-				$titre = _T("install_select_type_$s");
370
-				// proposer mysql par defaut si dispo
371
-				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
-			} else {
375
-				spip_log("$s: portage indisponible");
376
-			}
377
-		}
378
-	}
379
-	sort($options);
380
-
381
-	return $options;
355
+    $options = array();
356
+    $dir = _DIR_RESTREINT . 'req/';
357
+    $d = opendir($dir);
358
+    if (!$d) {
359
+        return array();
360
+    }
361
+    while (($f = readdir($d)) !== false) {
362
+        if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
+            and is_readable($f = $dir . $f)
364
+        ) {
365
+            require_once($f);
366
+            $s = $s[1];
367
+            $v = 'spip_versions_' . $s;
368
+            if (function_exists($v) and $v()) {
369
+                $titre = _T("install_select_type_$s");
370
+                // proposer mysql par defaut si dispo
371
+                $checked = ($s == 'mysql' ? " checked='checked'" : "");
372
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
+                    . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
+            } else {
375
+                spip_log("$s: portage indisponible");
376
+            }
377
+        }
378
+    }
379
+    sort($options);
380
+
381
+    return $options;
382 382
 }
383 383
 
384 384
 // https://code.spip.net/@install_connexion_form
385 385
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387
-
388
-	return generer_form_ecrire('install', (
389
-		"\n<input type='hidden' name='etape' value='$etape' />"
390
-		. $hidden
391
-		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
-			: "")
395
-
396
-		. ($jquery ? http_script('', 'jquery.js') : '')
397
-		. http_script('
386
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
387
+
388
+    return generer_form_ecrire('install', (
389
+        "\n<input type='hidden' name='etape' value='$etape' />"
390
+        . $hidden
391
+        . (_request('echec') ?
392
+            ("<p><b>" . _T('avis_connexion_echec_1') .
393
+                "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
+            : "")
395
+
396
+        . ($jquery ? http_script('', 'jquery.js') : '')
397
+        . http_script('
398 398
 		jQuery(function($) {
399 399
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
400 400
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -427,67 +427,67 @@  discard block
 block discarded – undo
427 427
 			});
428 428
 		});')
429 429
 
430
-		. ($server_db
431
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
-			. (($predef[0])
433
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
-				: '')
435
-			: ('<fieldset><legend>'
436
-				. _T('install_select_type_db')
437
-				. "</legend>"
438
-				. '<p class="explication">'
439
-				. _T('install_types_db_connus')
440
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
-				. '</p>'
443
-				. "\n<div class='p'>\n<ul>\n"
444
-				. join("\n", install_select_serveur())
445
-				. "\n</ul>\n</div></fieldset>")
446
-		)
447
-		. '<div id="install_adresse_base_hebergeur">'
448
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
449
-		. ($predef[1]
450
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
-			: fieldset(_T('entree_base_donnee_1'),
452
-				array(
453
-					'adresse_db' => array(
454
-						'label' => $db[1],
455
-						'valeur' => $db[0]
456
-					),
457
-				)
458
-			)
459
-		)
460
-		. '</div>'
461
-
462
-		. '<div id="install_login_base_hebergeur">'
463
-		. ($predef[2]
464
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
-			: fieldset(_T('entree_login_connexion_1'),
466
-				array(
467
-					'login_db' => array(
468
-						'label' => $login[1],
469
-						'valeur' => $login[0]
470
-					),
471
-				)
472
-			)
473
-		)
474
-		. '</div>'
475
-
476
-		. '<div id="install_pass_base_hebergeur">'
477
-		. ($predef[3]
478
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
-			: fieldset(_T('entree_mot_passe_1'),
480
-				array(
481
-					'pass_db' => array(
482
-						'label' => $pass[1],
483
-						'valeur' => $pass[0]
484
-					),
485
-				)
486
-			)
487
-		)
488
-		. '</div>'
489
-
490
-		. bouton_suivant()));
430
+        . ($server_db
431
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
+            . (($predef[0])
433
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
+                : '')
435
+            : ('<fieldset><legend>'
436
+                . _T('install_select_type_db')
437
+                . "</legend>"
438
+                . '<p class="explication">'
439
+                . _T('install_types_db_connus')
440
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
+                . '</p>'
443
+                . "\n<div class='p'>\n<ul>\n"
444
+                . join("\n", install_select_serveur())
445
+                . "\n</ul>\n</div></fieldset>")
446
+        )
447
+        . '<div id="install_adresse_base_hebergeur">'
448
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
449
+        . ($predef[1]
450
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
+            : fieldset(_T('entree_base_donnee_1'),
452
+                array(
453
+                    'adresse_db' => array(
454
+                        'label' => $db[1],
455
+                        'valeur' => $db[0]
456
+                    ),
457
+                )
458
+            )
459
+        )
460
+        . '</div>'
461
+
462
+        . '<div id="install_login_base_hebergeur">'
463
+        . ($predef[2]
464
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
+            : fieldset(_T('entree_login_connexion_1'),
466
+                array(
467
+                    'login_db' => array(
468
+                        'label' => $login[1],
469
+                        'valeur' => $login[0]
470
+                    ),
471
+                )
472
+            )
473
+        )
474
+        . '</div>'
475
+
476
+        . '<div id="install_pass_base_hebergeur">'
477
+        . ($predef[3]
478
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
+            : fieldset(_T('entree_mot_passe_1'),
480
+                array(
481
+                    'pass_db' => array(
482
+                        'label' => $pass[1],
483
+                        'valeur' => $pass[0]
484
+                    ),
485
+                )
486
+            )
487
+        )
488
+        . '</div>'
489
+
490
+        . bouton_suivant()));
491 491
 
492 492
 }
493 493
 
@@ -496,75 +496,75 @@  discard block
 block discarded – undo
496 496
 
497 497
 // https://code.spip.net/@predef_ou_cache
498 498
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
499
-	return ((defined('_INSTALL_HOST_DB'))
500
-		? ''
501
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
-	)
503
-	. ((defined('_INSTALL_USER_DB'))
504
-		? ''
505
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
-	)
507
-	. ((defined('_INSTALL_PASS_DB'))
508
-		? ''
509
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
-	)
511
-
512
-	. ((defined('_INSTALL_SERVER_DB'))
513
-		? ''
514
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
-	);
499
+    return ((defined('_INSTALL_HOST_DB'))
500
+        ? ''
501
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
+    )
503
+    . ((defined('_INSTALL_USER_DB'))
504
+        ? ''
505
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
+    )
507
+    . ((defined('_INSTALL_PASS_DB'))
508
+        ? ''
509
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
+    )
511
+
512
+    . ((defined('_INSTALL_SERVER_DB'))
513
+        ? ''
514
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
+    );
516 516
 }
517 517
 
518 518
 // presentation des bases existantes
519 519
 
520 520
 // https://code.spip.net/@install_etape_liste_bases
521 521
 function install_etape_liste_bases($server_db, $login_db, $disabled = array()) {
522
-	$bases = $checked = array();
523
-	$noms = sql_listdbs($server_db);
524
-	if (!$noms) {
525
-		return '';
526
-	}
527
-
528
-	foreach ($noms as $nom) {
529
-		$id = spip_htmlspecialchars($nom);
530
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
-		$base = " name=\"choix_db\" value=\""
532
-			. $nom
533
-			. '"'
534
-			. $dis
535
-			. " type='radio' id='$id'";
536
-		$label = "<label for='$id'>"
537
-			. ($dis ? "<i>$nom</i>" : $nom)
538
-			. "</label>";
539
-
540
-		if (!$checked and !$dis and
541
-			(($nom == $login_db) or
542
-				($GLOBALS['table_prefix'] == $nom))
543
-		) {
544
-			$checked = "<input$base checked='checked' />\n$label";
545
-		} else {
546
-			$bases[] = "<input$base />\n$label";
547
-		}
548
-	}
549
-
550
-	if (!$bases && !$checked) {
551
-		return false;
552
-	}
553
-
554
-	if ($checked) {
555
-		array_unshift($bases, $checked);
556
-		$checked = true;
557
-	}
558
-
559
-	return array($checked, $bases);
522
+    $bases = $checked = array();
523
+    $noms = sql_listdbs($server_db);
524
+    if (!$noms) {
525
+        return '';
526
+    }
527
+
528
+    foreach ($noms as $nom) {
529
+        $id = spip_htmlspecialchars($nom);
530
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
+        $base = " name=\"choix_db\" value=\""
532
+            . $nom
533
+            . '"'
534
+            . $dis
535
+            . " type='radio' id='$id'";
536
+        $label = "<label for='$id'>"
537
+            . ($dis ? "<i>$nom</i>" : $nom)
538
+            . "</label>";
539
+
540
+        if (!$checked and !$dis and
541
+            (($nom == $login_db) or
542
+                ($GLOBALS['table_prefix'] == $nom))
543
+        ) {
544
+            $checked = "<input$base checked='checked' />\n$label";
545
+        } else {
546
+            $bases[] = "<input$base />\n$label";
547
+        }
548
+    }
549
+
550
+    if (!$bases && !$checked) {
551
+        return false;
552
+    }
553
+
554
+    if ($checked) {
555
+        array_unshift($bases, $checked);
556
+        $checked = true;
557
+    }
558
+
559
+    return array($checked, $bases);
560 560
 }
561 561
 
562 562
 function install_propager($hidden) {
563
-	$res = '';
564
-	foreach ($hidden as $k) {
565
-		$v = spip_htmlentities(_request($k));
566
-		$res .= "<input type='hidden' name='$k' value='$v' />";
567
-	}
563
+    $res = '';
564
+    foreach ($hidden as $k) {
565
+        $v = spip_htmlentities(_request($k));
566
+        $res .= "<input type='hidden' name='$k' value='$v' />";
567
+    }
568 568
 
569
-	return $res;
569
+    return $res;
570 570
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
46
+	$texte = "<"."?php\n"
47 47
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48 48
 		. $texte
49
-		. "?" . ">";
49
+		. "?".">";
50 50
 
51 51
 	ecrire_fichier($nom, $texte);
52 52
 }
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 		return $regs;
114 114
 	} else {
115 115
 		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
116
+		$r = '\s*,'.$ar;
117 117
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118 118
 		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
119
+			$regs[2] = $regs[1].(!$regs[2] ? '' : ":".$regs[2].";");
120 120
 			array_shift($regs);
121 121
 			array_shift($regs);
122 122
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	// Si on n'a pas la bonne version de PHP, c'est la fin
175 175
 	if ($err) {
176 176
 		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
+			. "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
178 178
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179 179
 	}
180 180
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
 	if ($err) {
203 203
 		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
204
+			. "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
205 205
 		foreach ($err as $e) {
206 206
 			echo "<li><strong>$e</strong></li>\n";
207 207
 		}
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
 // https://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+	return "<h2>".$titre."</h2>\n".
239
+	($complement ? "".$complement."\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		$code = _T('bouton_suivant');
251 251
 	}
252 252
 	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
253
+	$id = 'suivant'.(($suivant > 0) ? strval($suivant) : '');
254 254
 	$suivant += 1;
255 255
 
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
256
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
257
+	$code.
258 258
 	" >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // https://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263 263
 	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
264
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
265 265
 	$debut = 1;
266 266
 	$etat = "ok";
267 267
 	$last = count($liste);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
302 302
 			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
303
+			$aff_etapes .= "<em>"._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304 304
 			$aff_etapes .= $intitule_etat["$phase"][$debut];
305 305
 			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306 306
 			$aff_etapes .= "</div></li>";
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 
317 317
 // https://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
319
+	return "<fieldset>\n".
320
+	$avant.
321
+	($legend ? "<legend>".$legend."</legend>\n" : '').
322
+	fieldset_champs($champs).
323
+	$apres.
324 324
 	"</fieldset>\n";
325 325
 }
326 326
 
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331 331
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332 332
 		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
333
+			$fieldset .= $contenu['label']."\n";
334 334
 			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
335
+				$fieldset .= "<input type='radio' name='".$nom.
336 336
 					"' id='$nom-$valeur' value='$valeur'"
337 337
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338 338
 					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
339
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
340 340
 			}
341 341
 			$fieldset .= "<br />\n";
342 342
 		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
343
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
344
+			$fieldset .= "<input ".$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
345 345
 				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346 346
 				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347 347
 				. " />\n";
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 
354 354
 function install_select_serveur() {
355 355
 	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
356
+	$dir = _DIR_RESTREINT.'req/';
357 357
 	$d = opendir($dir);
358 358
 	if (!$d) {
359 359
 		return array();
360 360
 	}
361 361
 	while (($f = readdir($d)) !== false) {
362 362
 		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
363
+			and is_readable($f = $dir.$f)
364 364
 		) {
365 365
 			require_once($f);
366 366
 			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
367
+			$v = 'spip_versions_'.$s;
368 368
 			if (function_exists($v) and $v()) {
369 369
 				$titre = _T("install_select_type_$s");
370 370
 				// proposer mysql par defaut si dispo
371 371
 				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372 372
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
373
+					. "<label for='$s'>".($titre ? $titre : $s)."</label></li>";
374 374
 			} else {
375 375
 				spip_log("$s: portage indisponible");
376 376
 			}
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 		"\n<input type='hidden' name='etape' value='$etape' />"
390 390
 		. $hidden
391 391
 		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
392
+			("<p><b>"._T('avis_connexion_echec_1').
393
+				"</b></p><p>"._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3')."</p>")
394 394
 			: "")
395 395
 
396 396
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 		});')
429 429
 
430 430
 		. ($server_db
431
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
431
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
432 432
 			. (($predef[0])
433
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
433
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
434 434
 				: '')
435 435
 			: ('<fieldset><legend>'
436 436
 				. _T('install_select_type_db')
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 				. "\n</ul>\n</div></fieldset>")
446 446
 		)
447 447
 		. '<div id="install_adresse_base_hebergeur">'
448
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
448
+		. '<p>'._T('texte_connexion_mysql').'</p>'
449 449
 		. ($predef[1]
450
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
450
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
451 451
 			: fieldset(_T('entree_base_donnee_1'),
452 452
 				array(
453 453
 					'adresse_db' => array(
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
 		. '<div id="install_login_base_hebergeur">'
463 463
 		. ($predef[2]
464
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
464
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
465 465
 			: fieldset(_T('entree_login_connexion_1'),
466 466
 				array(
467 467
 					'login_db' => array(
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 		. '<div id="install_pass_base_hebergeur">'
477 477
 		. ($predef[3]
478
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
478
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
479 479
 			: fieldset(_T('entree_mot_passe_1'),
480 480
 				array(
481 481
 					'pass_db' => array(
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
499 499
 	return ((defined('_INSTALL_HOST_DB'))
500 500
 		? ''
501
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
501
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db)."\" />"
502 502
 	)
503 503
 	. ((defined('_INSTALL_USER_DB'))
504 504
 		? ''
505
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
505
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db)."\" />"
506 506
 	)
507 507
 	. ((defined('_INSTALL_PASS_DB'))
508 508
 		? ''
509
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
509
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db)."\" />"
510 510
 	)
511 511
 
512 512
 	. ((defined('_INSTALL_SERVER_DB'))
513 513
 		? ''
514
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
514
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db)."\" />"
515 515
 	);
516 516
 }
517 517
 
Please login to merge, or discard this patch.
ecrire/inc/invalideur.php 2 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  * On ne calcule que la racine pour pour aller vite.
42 42
  *
43 43
  * @param string $dir Chemin du répertoire
44
- * @param string $nb_estim_taille Nombre de fichiers maximum pour estimer la taille
44
+ * @param integer $nb_estim_taille Nombre de fichiers maximum pour estimer la taille
45 45
  * @return bool|array
46 46
  *
47 47
  *     - false si le répertoire ne peut pas être ouvert
@@ -270,6 +270,10 @@  discard block
 block discarded – undo
270 270
 // (note: si absente, n'est pas appellee)
271 271
 
272 272
 // https://code.spip.net/@calcul_invalideurs
273
+/**
274
+ * @param string $corps
275
+ * @param string $id_boucle
276
+ */
273 277
 function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) {
274 278
 	if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) {
275 279
 		return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle);
@@ -292,6 +296,9 @@  discard block
 block discarded – undo
292 296
 
293 297
 // Calcul des pages : noter dans la base les liens d'invalidation
294 298
 // https://code.spip.net/@maj_invalideurs
299
+/**
300
+ * @param string $fichier
301
+ */
295 302
 function maj_invalideurs($fichier, &$page) {
296 303
 	if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) {
297 304
 		return $maj_invalideurs($fichier, $page);
Please login to merge, or discard this patch.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('base/serial');
24 24
 
25 25
 /** Estime la taille moyenne d'un fichier cache, pour ne pas les regarder (10ko) */
26 26
 if (!defined('_TAILLE_MOYENNE_FICHIER_CACHE')) {
27
-	define('_TAILLE_MOYENNE_FICHIER_CACHE', 1024 * 10);
27
+    define('_TAILLE_MOYENNE_FICHIER_CACHE', 1024 * 10);
28 28
 }
29 29
 /**
30 30
  * Si un fichier n'a pas été servi (fileatime) depuis plus d'une heure, on se sent
31 31
  * en droit de l'éliminer
32 32
  */
33 33
 if (!defined('_AGE_CACHE_ATIME')) {
34
-	define('_AGE_CACHE_ATIME', 3600);
34
+    define('_AGE_CACHE_ATIME', 3600);
35 35
 }
36 36
 
37 37
 /**
@@ -48,24 +48,24 @@  discard block
 block discarded – undo
48 48
  *     - array(nombre de fichiers, approximation de la taille en octet) sinon
49 49
  **/
50 50
 function nombre_de_fichiers_repertoire($dir, $nb_estim_taille = 20) {
51
-	$taille = 0; // mesurer la taille de N fichiers au hasard dans le repertoire
52
-	$nb = $nb_estim_taille;
53
-	if (!$h = opendir($dir)) {
54
-		return false;
55
-	}
56
-	$total = 0;
57
-	while (($fichier = @readdir($h)) !== false) {
58
-		if ($fichier[0] != '.' and !is_dir("$dir/$fichier")) {
59
-			$total++;
60
-			if ($nb and rand(1, 10) == 1) {
61
-				$taille += filesize("$dir/$fichier");
62
-				$nb--;
63
-			}
64
-		}
65
-	}
66
-	closedir($h);
67
-
68
-	return array($total, $taille ? $taille / ($nb_estim_taille - $nb) : _TAILLE_MOYENNE_FICHIER_CACHE);
51
+    $taille = 0; // mesurer la taille de N fichiers au hasard dans le repertoire
52
+    $nb = $nb_estim_taille;
53
+    if (!$h = opendir($dir)) {
54
+        return false;
55
+    }
56
+    $total = 0;
57
+    while (($fichier = @readdir($h)) !== false) {
58
+        if ($fichier[0] != '.' and !is_dir("$dir/$fichier")) {
59
+            $total++;
60
+            if ($nb and rand(1, 10) == 1) {
61
+                $taille += filesize("$dir/$fichier");
62
+                $nb--;
63
+            }
64
+        }
65
+    }
66
+    closedir($h);
67
+
68
+    return array($total, $taille ? $taille / ($nb_estim_taille - $nb) : _TAILLE_MOYENNE_FICHIER_CACHE);
69 69
 }
70 70
 
71 71
 
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
  * @return int Taille approximative en octets
79 79
  **/
80 80
 function taille_du_cache() {
81
-	# check dirs until we reach > 500 files
82
-	$t = 0;
83
-	$n = 0;
84
-	$time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0;
85
-	for ($i=0; $i < 256; $i++) {
86
-		$dir = _DIR_CACHE.sprintf('%02s', dechex($i));
87
-		if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
88
-			while (($f = readdir($d)) !== false) {
89
-				if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) {
90
-					$n++;
91
-					if ($a['mtime'] >= $time) {
92
-						if ($a['blocks'] > 0) {
93
-							$t += 512*$a['blocks'];
94
-						} else {
95
-							$t += $a['size'];
96
-						}
97
-					}
98
-				}
99
-			}
100
-		}
101
-		if ($n > 500) {
102
-			return intval(256*$t/(1+$i));
103
-		}
104
-	}
105
-	return $t;
81
+    # check dirs until we reach > 500 files
82
+    $t = 0;
83
+    $n = 0;
84
+    $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0;
85
+    for ($i=0; $i < 256; $i++) {
86
+        $dir = _DIR_CACHE.sprintf('%02s', dechex($i));
87
+        if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
88
+            while (($f = readdir($d)) !== false) {
89
+                if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) {
90
+                    $n++;
91
+                    if ($a['mtime'] >= $time) {
92
+                        if ($a['blocks'] > 0) {
93
+                            $t += 512*$a['blocks'];
94
+                        } else {
95
+                            $t += $a['size'];
96
+                        }
97
+                    }
98
+                }
99
+            }
100
+        }
101
+        if ($n > 500) {
102
+            return intval(256*$t/(1+$i));
103
+        }
104
+    }
105
+    return $t;
106 106
 }
107 107
 
108 108
 
@@ -129,30 +129,30 @@  discard block
 block discarded – undo
129 129
  *     Inutilisé
130 130
  **/
131 131
 function inc_suivre_invalideur_dist($cond, $modif = true) {
132
-	if (!$modif) {
133
-		return;
134
-	}
135
-
136
-	// determiner l'objet modifie : forum, article, etc
137
-	if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) {
138
-		$objet = objet_type($r[1]);
139
-	}
140
-
141
-	// stocker la date_modif_$objet (ne sert a rien pour le moment)
142
-	if (isset($objet)) {
143
-		ecrire_meta('derniere_modif_' . $objet, time());
144
-	}
145
-
146
-	// si $derniere_modif_invalide est un array('article', 'rubrique')
147
-	// n'affecter la meta que si un de ces objets est modifie
148
-	if (is_array($GLOBALS['derniere_modif_invalide'])) {
149
-		if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) {
150
-			ecrire_meta('derniere_modif', time());
151
-		}
152
-	} // sinon, cas standard, toujours affecter la meta
153
-	else {
154
-		ecrire_meta('derniere_modif', time());
155
-	}
132
+    if (!$modif) {
133
+        return;
134
+    }
135
+
136
+    // determiner l'objet modifie : forum, article, etc
137
+    if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) {
138
+        $objet = objet_type($r[1]);
139
+    }
140
+
141
+    // stocker la date_modif_$objet (ne sert a rien pour le moment)
142
+    if (isset($objet)) {
143
+        ecrire_meta('derniere_modif_' . $objet, time());
144
+    }
145
+
146
+    // si $derniere_modif_invalide est un array('article', 'rubrique')
147
+    // n'affecter la meta que si un de ces objets est modifie
148
+    if (is_array($GLOBALS['derniere_modif_invalide'])) {
149
+        if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) {
150
+            ecrire_meta('derniere_modif', time());
151
+        }
152
+    } // sinon, cas standard, toujours affecter la meta
153
+    else {
154
+        ecrire_meta('derniere_modif', time());
155
+    }
156 156
 }
157 157
 
158 158
 
@@ -177,49 +177,49 @@  discard block
 block discarded – undo
177 177
  *     Nombre de fichiers supprimés
178 178
  **/
179 179
 function purger_repertoire($dir, $options = array()) {
180
-	if (!is_dir($dir) or !is_readable($dir)) {
181
-		return;
182
-	}
183
-	$handle = opendir($dir);
184
-	if (!$handle) {
185
-		return;
186
-	}
187
-
188
-	$total = 0;
189
-
190
-	while (($fichier = @readdir($handle)) !== false) {
191
-		// Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG
192
-		if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') {
193
-			continue;
194
-		}
195
-		$chemin = "$dir/$fichier";
196
-		if (is_file($chemin)) {
197
-			if ((!isset($options['atime']) or (@fileatime($chemin) < $options['atime']))
198
-				and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime']))
199
-			) {
200
-				supprimer_fichier($chemin);
201
-				$total++;
202
-			}
203
-		} else {
204
-			if (is_dir($chemin)) {
205
-				$opts = $options;
206
-				if (isset($options['limit'])) {
207
-					$opts['limit'] = $options['limit'] - $total;
208
-				}
209
-				$total += purger_repertoire($chemin, $opts);
210
-				if (isset($options['subdir']) && $options['subdir']) {
211
-					spip_unlink($chemin);
212
-				}
213
-			}
214
-		}
215
-
216
-		if (isset($options['limit']) and $total >= $options['limit']) {
217
-			break;
218
-		}
219
-	}
220
-	closedir($handle);
221
-
222
-	return $total;
180
+    if (!is_dir($dir) or !is_readable($dir)) {
181
+        return;
182
+    }
183
+    $handle = opendir($dir);
184
+    if (!$handle) {
185
+        return;
186
+    }
187
+
188
+    $total = 0;
189
+
190
+    while (($fichier = @readdir($handle)) !== false) {
191
+        // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG
192
+        if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') {
193
+            continue;
194
+        }
195
+        $chemin = "$dir/$fichier";
196
+        if (is_file($chemin)) {
197
+            if ((!isset($options['atime']) or (@fileatime($chemin) < $options['atime']))
198
+                and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime']))
199
+            ) {
200
+                supprimer_fichier($chemin);
201
+                $total++;
202
+            }
203
+        } else {
204
+            if (is_dir($chemin)) {
205
+                $opts = $options;
206
+                if (isset($options['limit'])) {
207
+                    $opts['limit'] = $options['limit'] - $total;
208
+                }
209
+                $total += purger_repertoire($chemin, $opts);
210
+                if (isset($options['subdir']) && $options['subdir']) {
211
+                    spip_unlink($chemin);
212
+                }
213
+            }
214
+        }
215
+
216
+        if (isset($options['limit']) and $total >= $options['limit']) {
217
+            break;
218
+        }
219
+    }
220
+    closedir($handle);
221
+
222
+    return $total;
223 223
 }
224 224
 
225 225
 
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 // https://code.spip.net/@retire_cache
232 232
 function retire_cache($cache) {
233 233
 
234
-	if (preg_match(
235
-		',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i',
236
-		$cache
237
-	)) {
238
-		// supprimer le fichier (de facon propre)
239
-		supprimer_fichier(_DIR_CACHE . $cache);
240
-	} else {
241
-		spip_log("Nom de fichier cache incorrect : $cache");
242
-	}
234
+    if (preg_match(
235
+        ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i',
236
+        $cache
237
+    )) {
238
+        // supprimer le fichier (de facon propre)
239
+        supprimer_fichier(_DIR_CACHE . $cache);
240
+    } else {
241
+        spip_log("Nom de fichier cache incorrect : $cache");
242
+    }
243 243
 }
244 244
 
245 245
 // Supprimer les caches marques "x"
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 // la meta est toujours false ; mais evitons un bug si elle est appellee
248 248
 // https://code.spip.net/@retire_caches
249 249
 function inc_retire_caches_dist($chemin = '') {
250
-	if (isset($GLOBALS['meta']['invalider_caches'])) {
251
-		effacer_meta('invalider_caches');
252
-	} # concurrence
250
+    if (isset($GLOBALS['meta']['invalider_caches'])) {
251
+        effacer_meta('invalider_caches');
252
+    } # concurrence
253 253
 }
254 254
 
255 255
 #######################################################################
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 ##
261 261
 
262 262
 function retire_caches($chemin = '') {
263
-	if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) {
264
-		return $retire_caches($chemin);
265
-	}
263
+    if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) {
264
+        return $retire_caches($chemin);
265
+    }
266 266
 }
267 267
 
268 268
 
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
 
272 272
 // https://code.spip.net/@calcul_invalideurs
273 273
 function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) {
274
-	if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) {
275
-		return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle);
276
-	}
277
-	return $corps;
274
+    if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) {
275
+        return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle);
276
+    }
277
+    return $corps;
278 278
 }
279 279
 
280 280
 
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
 //
285 285
 // https://code.spip.net/@supprime_invalideurs
286 286
 function supprime_invalideurs() {
287
-	if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) {
288
-		return $supprime_invalideurs();
289
-	}
287
+    if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) {
288
+        return $supprime_invalideurs();
289
+    }
290 290
 }
291 291
 
292 292
 
293 293
 // Calcul des pages : noter dans la base les liens d'invalidation
294 294
 // https://code.spip.net/@maj_invalideurs
295 295
 function maj_invalideurs($fichier, &$page) {
296
-	if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) {
297
-		return $maj_invalideurs($fichier, $page);
298
-	}
296
+    if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) {
297
+        return $maj_invalideurs($fichier, $page);
298
+    }
299 299
 }
300 300
 
301 301
 
302 302
 // les invalideurs sont de la forme "objet/id_objet"
303 303
 // https://code.spip.net/@insere_invalideur
304 304
 function insere_invalideur($inval, $fichier) {
305
-	if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) {
306
-		return $insere_invalideur($inval, $fichier);
307
-	}
305
+    if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) {
306
+        return $insere_invalideur($inval, $fichier);
307
+    }
308 308
 }
309 309
 
310 310
 //
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
 //
313 313
 // https://code.spip.net/@applique_invalideur
314 314
 function applique_invalideur($depart) {
315
-	if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) {
316
-		return $applique_invalideur($depart);
317
-	}
315
+    if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) {
316
+        return $applique_invalideur($depart);
317
+    }
318 318
 }
319 319
 
320 320
 //
321 321
 // Invalider les caches liés à telle condition
322 322
 //
323 323
 function suivre_invalideur($cond, $modif = true) {
324
-	if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) {
325
-		return $suivre_invalideur($cond, $modif);
326
-	}
324
+    if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) {
325
+        return $suivre_invalideur($cond, $modif);
326
+    }
327 327
 }
328 328
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/inc/lang.php 3 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @param string $lang
33 33
  *     La langue à utiliser
34
- * @return string|bool
34
+ * @return false|string
35 35
  *     string : La langue qui a été utilisée si trouvée
36 36
  *     false : aucune langue ne correspondait à la demande
37 37
  **/
@@ -80,6 +80,9 @@  discard block
 block discarded – undo
80 80
 // retourne son 2e argument si c'est un index du premier
81 81
 // ou un index approchant sinon et si possible, 
82 82
 // la langue X etant consideree comme une approche de X_Y
83
+/**
84
+ * @return string
85
+ */
83 86
 function approcher_langue($trads, $lang = '') {
84 87
 
85 88
 	if (!$lang) {
@@ -175,6 +178,9 @@  discard block
 block discarded – undo
175 178
 // pour 'changer_lang' (langue de l'article, espace prive), c'est en Ajax
176 179
 // 
177 180
 // https://code.spip.net/@menu_langues
181
+/**
182
+ * @param string $nom_select
183
+ */
178 184
 function menu_langues($nom_select, $default = '') {
179 185
 	include_spip('inc/actions');
180 186
 
@@ -209,6 +215,10 @@  discard block
 block discarded – undo
209 215
 }
210 216
 
211 217
 // https://code.spip.net/@select_langues
218
+/**
219
+ * @param string $change
220
+ * @param string $options
221
+ */
212 222
 function select_langues($nom_select, $change, $options, $label = "") {
213 223
 	static $cpt = 0;
214 224
 	$id = "menu_langues" . $cpt++;
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Langue
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
  **/
38 38
 function changer_langue($lang) {
39 39
 
40
-	$liste_langues = ',' . @$GLOBALS['meta']['langues_proposees']
41
-		. ',' . @$GLOBALS['meta']['langues_multilingue'] . ',';
42
-
43
-	// Si la langue demandee n'existe pas, on essaie d'autres variantes
44
-	// Exemple : 'pt-br' => 'pt_br' => 'pt'
45
-	$lang = str_replace('-', '_', trim($lang));
46
-	if (!$lang) {
47
-		return false;
48
-	}
49
-
50
-	if (strpos($liste_langues, ",$lang,") !== false
51
-		or ($lang = preg_replace(',_.*,', '', $lang)
52
-			and strpos($liste_langues, ",$lang,") !== false)
53
-	) {
54
-
55
-		$GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
56
-		$GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
57
-		$GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
58
-
59
-		return $GLOBALS['spip_lang'] = $lang;
60
-	} else {
61
-		return false;
62
-	}
40
+    $liste_langues = ',' . @$GLOBALS['meta']['langues_proposees']
41
+        . ',' . @$GLOBALS['meta']['langues_multilingue'] . ',';
42
+
43
+    // Si la langue demandee n'existe pas, on essaie d'autres variantes
44
+    // Exemple : 'pt-br' => 'pt_br' => 'pt'
45
+    $lang = str_replace('-', '_', trim($lang));
46
+    if (!$lang) {
47
+        return false;
48
+    }
49
+
50
+    if (strpos($liste_langues, ",$lang,") !== false
51
+        or ($lang = preg_replace(',_.*,', '', $lang)
52
+            and strpos($liste_langues, ",$lang,") !== false)
53
+    ) {
54
+
55
+        $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
56
+        $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
57
+        $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
58
+
59
+        return $GLOBALS['spip_lang'] = $lang;
60
+    } else {
61
+        return false;
62
+    }
63 63
 }
64 64
 
65 65
 //
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 // par exemple le francais pour l'espagnol, l'anglais pour l'allemand, etc.
73 73
 
74 74
 function choisir_traduction($trads, $lang = '') {
75
-	$k = approcher_langue($trads, $lang);
75
+    $k = approcher_langue($trads, $lang);
76 76
 
77
-	return $k ? $trads[$k] : array_shift($trads);
77
+    return $k ? $trads[$k] : array_shift($trads);
78 78
 }
79 79
 
80 80
 // retourne son 2e argument si c'est un index du premier
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
 // la langue X etant consideree comme une approche de X_Y
83 83
 function approcher_langue($trads, $lang = '') {
84 84
 
85
-	if (!$lang) {
86
-		$lang = $GLOBALS['spip_lang'];
87
-	}
88
-
89
-	if (isset($trads[$lang])) {
90
-		return $lang;
91
-	} // cas des langues xx_yy
92
-	else {
93
-		$r = explode('_', $lang);
94
-		if (isset($trads[$r[0]])) {
95
-			return $r[0];
96
-		}
97
-	}
98
-
99
-	return '';
85
+    if (!$lang) {
86
+        $lang = $GLOBALS['spip_lang'];
87
+    }
88
+
89
+    if (isset($trads[$lang])) {
90
+        return $lang;
91
+    } // cas des langues xx_yy
92
+    else {
93
+        $r = explode('_', $lang);
94
+        if (isset($trads[$r[0]])) {
95
+            return $r[0];
96
+        }
97
+    }
98
+
99
+    return '';
100 100
 }
101 101
 
102 102
 /**
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
  *     Nom de la langue, sinon son code.
112 112
  **/
113 113
 function traduire_nom_langue($lang) {
114
-	include_spip('inc/lang_liste');
115
-	include_spip('inc/charsets');
114
+    include_spip('inc/lang_liste');
115
+    include_spip('inc/charsets');
116 116
 
117
-	return html2unicode(isset($GLOBALS['codes_langues'][$lang]) ? $GLOBALS['codes_langues'][$lang] : $lang);
117
+    return html2unicode(isset($GLOBALS['codes_langues'][$lang]) ? $GLOBALS['codes_langues'][$lang] : $lang);
118 118
 }
119 119
 
120 120
 //
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 // C'est utilise par #LANG_DIR, #LANG_LEFT, #LANG_RIGHT.
129 129
 // https://code.spip.net/@lang_dir
130 130
 function lang_dir($lang = '', $droitier = 'ltr', $gaucher = 'rtl') {
131
-	static $lang_rtl = array('ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi');
131
+    static $lang_rtl = array('ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi');
132 132
 
133
-	return in_array(($lang ? $lang : $GLOBALS['spip_lang']), $lang_rtl) ?
134
-		$gaucher : $droitier;
133
+    return in_array(($lang ? $lang : $GLOBALS['spip_lang']), $lang_rtl) ?
134
+        $gaucher : $droitier;
135 135
 }
136 136
 
137 137
 // typo francaise ou anglaise ?
@@ -141,31 +141,31 @@  discard block
 block discarded – undo
141 141
 
142 142
 // https://code.spip.net/@lang_typo
143 143
 function lang_typo($lang = '') {
144
-	if (!$lang) {
145
-		$lang = isset($GLOBALS['lang_objet'])
146
-			? $GLOBALS['lang_objet']
147
-			: $GLOBALS['spip_lang'];
148
-	}
149
-	if ($lang == 'eo'
150
-		or $lang == 'fr'
151
-		or strncmp($lang, 'fr_', 3) == 0
152
-		or $lang == 'cpf'
153
-	) {
154
-		return 'fr';
155
-	} else {
156
-		return 'en';
157
-	}
144
+    if (!$lang) {
145
+        $lang = isset($GLOBALS['lang_objet'])
146
+            ? $GLOBALS['lang_objet']
147
+            : $GLOBALS['spip_lang'];
148
+    }
149
+    if ($lang == 'eo'
150
+        or $lang == 'fr'
151
+        or strncmp($lang, 'fr_', 3) == 0
152
+        or $lang == 'cpf'
153
+    ) {
154
+        return 'fr';
155
+    } else {
156
+        return 'en';
157
+    }
158 158
 }
159 159
 
160 160
 // gestion de la globale $lang_objet pour que les textes soient affiches
161 161
 // avec les memes typo et direction dans l'espace prive que dans le public
162 162
 // https://code.spip.net/@changer_typo
163 163
 function changer_typo($lang = '') {
164
-	if ($lang) {
165
-		$GLOBALS['lang_objet'] = $lang;
166
-	} else {
167
-		unset($GLOBALS['lang_objet']);
168
-	}
164
+    if ($lang) {
165
+        $GLOBALS['lang_objet'] = $lang;
166
+    } else {
167
+        unset($GLOBALS['lang_objet']);
168
+    }
169 169
 }
170 170
 
171 171
 //
@@ -176,55 +176,55 @@  discard block
 block discarded – undo
176 176
 // 
177 177
 // https://code.spip.net/@menu_langues
178 178
 function menu_langues($nom_select, $default = '') {
179
-	include_spip('inc/actions');
180
-
181
-	$langues = liste_options_langues($nom_select);
182
-	$ret = "";
183
-	if (!count($langues)) {
184
-		return '';
185
-	}
186
-
187
-	if (!$default) {
188
-		$default = $GLOBALS['spip_lang'];
189
-	}
190
-	foreach ($langues as $l) {
191
-		$selected = ($l == $default) ? ' selected=\'selected\'' : '';
192
-		$ret .= "<option value='$l'$selected>[" . $l . "] " . traduire_nom_langue($l) . "</option>\n";
193
-	}
194
-
195
-	if (!test_espace_prive()) {
196
-		$cible = self();
197
-		$base = '';
198
-	} else {
199
-		$cible = self();
200
-		$base = spip_connect() ? 'base' : '';
201
-	}
202
-
203
-	$change = ' onchange="this.parentNode.parentNode.submit()"';
204
-
205
-	return generer_action_auteur('converser', $base, $cible,
206
-		(select_langues($nom_select, $change, $ret)
207
-			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
208
-		" method='post'");
179
+    include_spip('inc/actions');
180
+
181
+    $langues = liste_options_langues($nom_select);
182
+    $ret = "";
183
+    if (!count($langues)) {
184
+        return '';
185
+    }
186
+
187
+    if (!$default) {
188
+        $default = $GLOBALS['spip_lang'];
189
+    }
190
+    foreach ($langues as $l) {
191
+        $selected = ($l == $default) ? ' selected=\'selected\'' : '';
192
+        $ret .= "<option value='$l'$selected>[" . $l . "] " . traduire_nom_langue($l) . "</option>\n";
193
+    }
194
+
195
+    if (!test_espace_prive()) {
196
+        $cible = self();
197
+        $base = '';
198
+    } else {
199
+        $cible = self();
200
+        $base = spip_connect() ? 'base' : '';
201
+    }
202
+
203
+    $change = ' onchange="this.parentNode.parentNode.submit()"';
204
+
205
+    return generer_action_auteur('converser', $base, $cible,
206
+        (select_langues($nom_select, $change, $ret)
207
+            . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
208
+        " method='post'");
209 209
 }
210 210
 
211 211
 // https://code.spip.net/@select_langues
212 212
 function select_langues($nom_select, $change, $options, $label = "") {
213
-	static $cpt = 0;
214
-	$id = "menu_langues" . $cpt++;
215
-
216
-	return
217
-		"<label for='$id'>" . ($label ? $label : _T('info_langues')) . "</label> " .
218
-		"<select name='$nom_select' id='$id' "
219
-		. ((!test_espace_prive()) ?
220
-			("class='forml menu_langues'") :
221
-			(($nom_select == 'var_lang_ecrire') ?
222
-				("class='lang_ecrire'") :
223
-				"class='fondl'"))
224
-		. $change
225
-		. ">\n"
226
-		. $options
227
-		. "</select>";
213
+    static $cpt = 0;
214
+    $id = "menu_langues" . $cpt++;
215
+
216
+    return
217
+        "<label for='$id'>" . ($label ? $label : _T('info_langues')) . "</label> " .
218
+        "<select name='$nom_select' id='$id' "
219
+        . ((!test_espace_prive()) ?
220
+            ("class='forml menu_langues'") :
221
+            (($nom_select == 'var_lang_ecrire') ?
222
+                ("class='lang_ecrire'") :
223
+                "class='fondl'"))
224
+        . $change
225
+        . ">\n"
226
+        . $options
227
+        . "</select>";
228 228
 }
229 229
 
230 230
 /**
@@ -246,34 +246,34 @@  discard block
 block discarded – undo
246 246
  */
247 247
 function liste_options_langues($nom_select) {
248 248
 
249
-	switch ($nom_select) {
250
-		# #MENU_LANG
251
-		case 'var_lang':
252
-			# menu de changement de la langue d'un article
253
-			# les langues selectionnees dans la configuration "multilinguisme"
254
-		case 'changer_lang':
255
-			$langues = explode(',', $GLOBALS['meta']['langues_multilingue']);
256
-			break;
257
-		# menu de l'interface (privee, installation et panneau de login)
258
-		# les langues presentes sous forme de fichiers de langue
259
-		# on force la relecture du repertoire des langues pour etre synchrone.
260
-		case 'var_lang_ecrire':
261
-		default:
262
-			$GLOBALS['meta']['langues_proposees'] = '';
263
-			init_langues();
264
-			$langues = explode(',', $GLOBALS['meta']['langues_proposees']);
265
-			break;
249
+    switch ($nom_select) {
250
+        # #MENU_LANG
251
+        case 'var_lang':
252
+            # menu de changement de la langue d'un article
253
+            # les langues selectionnees dans la configuration "multilinguisme"
254
+        case 'changer_lang':
255
+            $langues = explode(',', $GLOBALS['meta']['langues_multilingue']);
256
+            break;
257
+        # menu de l'interface (privee, installation et panneau de login)
258
+        # les langues presentes sous forme de fichiers de langue
259
+        # on force la relecture du repertoire des langues pour etre synchrone.
260
+        case 'var_lang_ecrire':
261
+        default:
262
+            $GLOBALS['meta']['langues_proposees'] = '';
263
+            init_langues();
264
+            $langues = explode(',', $GLOBALS['meta']['langues_proposees']);
265
+            break;
266 266
 
267 267
 # dernier choix possible : toutes les langues = langues_proposees 
268 268
 # + langues_multilingues ; mais, ne sert pas
269 269
 #			$langues = explode(',', $GLOBALS['all_langs']);
270
-	}
271
-	if (count($langues) <= 1) {
272
-		return array();
273
-	}
274
-	sort($langues);
270
+    }
271
+    if (count($langues) <= 1) {
272
+        return array();
273
+    }
274
+    sort($langues);
275 275
 
276
-	return $langues;
276
+    return $langues;
277 277
 }
278 278
 
279 279
 
@@ -288,38 +288,38 @@  discard block
 block discarded – undo
288 288
  **/
289 289
 function verifier_lang_url() {
290 290
 
291
-	// quelle langue est demandee ?
292
-	$lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
293
-	if (isset($_COOKIE['spip_lang_ecrire'])) {
294
-		$lang_demandee = $_COOKIE['spip_lang_ecrire'];
295
-	}
296
-	if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) {
297
-		$lang_demandee = $_COOKIE['spip_lang'];
298
-	}
299
-	if (isset($_GET['lang'])) {
300
-		$lang_demandee = $_GET['lang'];
301
-	}
302
-
303
-	// Renvoyer si besoin (et si la langue demandee existe)
304
-	if ($GLOBALS['spip_lang'] != $lang_demandee
305
-		and changer_langue($lang_demandee)
306
-		and $lang_demandee != @$_GET['lang']
307
-	) {
308
-		$destination = parametre_url(self(), 'lang', $lang_demandee, '&');
309
-		// ici on a besoin des var_truc
310
-		foreach ($_GET as $var => $val) {
311
-			if (!strncmp('var_', $var, 4)) {
312
-				$destination = parametre_url($destination, $var, $val, '&');
313
-			}
314
-		}
315
-		include_spip('inc/headers');
316
-		redirige_par_entete($destination);
317
-	}
318
-
319
-	// Subtilite : si la langue demandee par cookie est la bonne
320
-	// alors on fait comme si $lang etait passee dans l'URL
321
-	// (pour criteres {lang}).
322
-	$GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
291
+    // quelle langue est demandee ?
292
+    $lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
293
+    if (isset($_COOKIE['spip_lang_ecrire'])) {
294
+        $lang_demandee = $_COOKIE['spip_lang_ecrire'];
295
+    }
296
+    if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) {
297
+        $lang_demandee = $_COOKIE['spip_lang'];
298
+    }
299
+    if (isset($_GET['lang'])) {
300
+        $lang_demandee = $_GET['lang'];
301
+    }
302
+
303
+    // Renvoyer si besoin (et si la langue demandee existe)
304
+    if ($GLOBALS['spip_lang'] != $lang_demandee
305
+        and changer_langue($lang_demandee)
306
+        and $lang_demandee != @$_GET['lang']
307
+    ) {
308
+        $destination = parametre_url(self(), 'lang', $lang_demandee, '&');
309
+        // ici on a besoin des var_truc
310
+        foreach ($_GET as $var => $val) {
311
+            if (!strncmp('var_', $var, 4)) {
312
+                $destination = parametre_url($destination, $var, $val, '&');
313
+            }
314
+        }
315
+        include_spip('inc/headers');
316
+        redirige_par_entete($destination);
317
+    }
318
+
319
+    // Subtilite : si la langue demandee par cookie est la bonne
320
+    // alors on fait comme si $lang etait passee dans l'URL
321
+    // (pour criteres {lang}).
322
+    $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
323 323
 }
324 324
 
325 325
 
@@ -335,21 +335,21 @@  discard block
 block discarded – undo
335 335
  *     La langue sélectionnée
336 336
  **/
337 337
 function utiliser_langue_site() {
338
-	// s'il existe une langue du site (en gros tout le temps en théorie)
339
-	if (isset($GLOBALS['meta']['langue_site'])
340
-		// et si spip_langue est pas encore définie (ce que va faire changer_langue())
341
-		// ou qu'elle n'est pas identique à la langue du site
342
-		and (!isset($GLOBALS['spip_lang'])
343
-			or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
344
-	) {
345
-		return changer_langue($GLOBALS['meta']['langue_site']);//@:install
346
-	}
347
-	// en theorie là, la globale est définie, sinon c'est un problème.
348
-	if (!isset($GLOBALS['spip_lang'])) {
349
-		spip_log("La globale spip_lang est indéfinie dans utiliser_langue_site() !", _LOG_ERREUR);
350
-	}
351
-
352
-	return $GLOBALS['spip_lang'];
338
+    // s'il existe une langue du site (en gros tout le temps en théorie)
339
+    if (isset($GLOBALS['meta']['langue_site'])
340
+        // et si spip_langue est pas encore définie (ce que va faire changer_langue())
341
+        // ou qu'elle n'est pas identique à la langue du site
342
+        and (!isset($GLOBALS['spip_lang'])
343
+            or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
344
+    ) {
345
+        return changer_langue($GLOBALS['meta']['langue_site']);//@:install
346
+    }
347
+    // en theorie là, la globale est définie, sinon c'est un problème.
348
+    if (!isset($GLOBALS['spip_lang'])) {
349
+        spip_log("La globale spip_lang est indéfinie dans utiliser_langue_site() !", _LOG_ERREUR);
350
+    }
351
+
352
+    return $GLOBALS['spip_lang'];
353 353
 }
354 354
 
355 355
 /**
@@ -366,30 +366,30 @@  discard block
 block discarded – undo
366 366
  **/
367 367
 function utiliser_langue_visiteur() {
368 368
 
369
-	$l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire');
370
-	if (isset($_COOKIE[$l])) {
371
-		if (changer_langue($l = $_COOKIE[$l])) {
372
-			return $l;
373
-		}
374
-	}
375
-
376
-	if (isset($GLOBALS['visiteur_session']['lang'])) {
377
-		if (changer_langue($l = $GLOBALS['visiteur_session']['lang'])) {
378
-			return $l;
379
-		}
380
-	}
381
-
382
-	if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
383
-		foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
384
-			if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) {
385
-				if (changer_langue($l = strtolower($r[1]))) {
386
-					return $l;
387
-				}
388
-			}
389
-		}
390
-	}
391
-
392
-	return utiliser_langue_site();
369
+    $l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire');
370
+    if (isset($_COOKIE[$l])) {
371
+        if (changer_langue($l = $_COOKIE[$l])) {
372
+            return $l;
373
+        }
374
+    }
375
+
376
+    if (isset($GLOBALS['visiteur_session']['lang'])) {
377
+        if (changer_langue($l = $GLOBALS['visiteur_session']['lang'])) {
378
+            return $l;
379
+        }
380
+    }
381
+
382
+    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
383
+        foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
384
+            if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) {
385
+                if (changer_langue($l = strtolower($r[1]))) {
386
+                    return $l;
387
+                }
388
+            }
389
+        }
390
+    }
391
+
392
+    return utiliser_langue_site();
393 393
 }
394 394
 
395 395
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
  * @return int
400 400
  */
401 401
 function match_langue($chaine) {
402
-	return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
402
+    return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
403 403
 }
404 404
 
405 405
 /**
@@ -417,36 +417,36 @@  discard block
 block discarded – undo
417 417
  **/
418 418
 function init_langues() {
419 419
 
420
-	// liste des langues dans les meta, sauf a l'install
421
-	$all_langs = @$GLOBALS['meta']['langues_proposees'];
422
-
423
-	$tout = array();
424
-	if (!$all_langs) {
425
-		// trouver tous les modules lang/spip_xx.php
426
-		$modules = find_all_in_path("lang/", "/spip_([a-z_]+)\.php$");
427
-		foreach ($modules as $name => $path) {
428
-			if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) {
429
-				if (match_langue($regs[1])) {
430
-					$tout[] = $regs[1];
431
-				}
432
-			}
433
-		}
434
-		sort($tout);
435
-		$tout = join(',', $tout);
436
-		// Si les langues n'ont pas change, ne rien faire
437
-		if ($tout != $all_langs) {
438
-			$GLOBALS['meta']['langues_proposees'] = $tout;
439
-			include_spip('inc/meta');
440
-			ecrire_meta('langues_proposees', $tout);
441
-		}
442
-	}
443
-	if (!isset($GLOBALS['meta']['langue_site'])) {
444
-		// Initialisation : le francais si dispo, sinon la premiere langue trouvee
445
-		$GLOBALS['meta']['langue_site'] = $tout =
446
-			(!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', ",$all_langs,") !== false))
447
-				? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ','));
448
-		ecrire_meta('langue_site', $tout);
449
-	}
420
+    // liste des langues dans les meta, sauf a l'install
421
+    $all_langs = @$GLOBALS['meta']['langues_proposees'];
422
+
423
+    $tout = array();
424
+    if (!$all_langs) {
425
+        // trouver tous les modules lang/spip_xx.php
426
+        $modules = find_all_in_path("lang/", "/spip_([a-z_]+)\.php$");
427
+        foreach ($modules as $name => $path) {
428
+            if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) {
429
+                if (match_langue($regs[1])) {
430
+                    $tout[] = $regs[1];
431
+                }
432
+            }
433
+        }
434
+        sort($tout);
435
+        $tout = join(',', $tout);
436
+        // Si les langues n'ont pas change, ne rien faire
437
+        if ($tout != $all_langs) {
438
+            $GLOBALS['meta']['langues_proposees'] = $tout;
439
+            include_spip('inc/meta');
440
+            ecrire_meta('langues_proposees', $tout);
441
+        }
442
+    }
443
+    if (!isset($GLOBALS['meta']['langue_site'])) {
444
+        // Initialisation : le francais si dispo, sinon la premiere langue trouvee
445
+        $GLOBALS['meta']['langue_site'] = $tout =
446
+            (!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', ",$all_langs,") !== false))
447
+                ? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ','));
448
+        ecrire_meta('langue_site', $tout);
449
+    }
450 450
 }
451 451
 
452 452
 /**
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
  *     Code html de la balise <html>
461 461
  **/
462 462
 function html_lang_attributes() {
463
-	$lang = $GLOBALS['spip_lang'];
464
-	$dir = ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr');
463
+    $lang = $GLOBALS['spip_lang'];
464
+    $dir = ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr');
465 465
 
466
-	return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
466
+    return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
467 467
 }
468 468
 
469 469
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  * @return string
478 478
  */
479 479
 function aide_lang_dir($spip_lang, $spip_lang_rtl) {
480
-	return ($spip_lang <> 'he') ? $spip_lang_rtl : '';
480
+    return ($spip_lang <> 'he') ? $spip_lang_rtl : '';
481 481
 }
482 482
 
483 483
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
  **/
38 38
 function changer_langue($lang) {
39 39
 
40
-	$liste_langues = ',' . @$GLOBALS['meta']['langues_proposees']
41
-		. ',' . @$GLOBALS['meta']['langues_multilingue'] . ',';
40
+	$liste_langues = ','.@$GLOBALS['meta']['langues_proposees']
41
+		. ','.@$GLOBALS['meta']['langues_multilingue'].',';
42 42
 
43 43
 	// Si la langue demandee n'existe pas, on essaie d'autres variantes
44 44
 	// Exemple : 'pt-br' => 'pt_br' => 'pt'
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 	foreach ($langues as $l) {
191 191
 		$selected = ($l == $default) ? ' selected=\'selected\'' : '';
192
-		$ret .= "<option value='$l'$selected>[" . $l . "] " . traduire_nom_langue($l) . "</option>\n";
192
+		$ret .= "<option value='$l'$selected>[".$l."] ".traduire_nom_langue($l)."</option>\n";
193 193
 	}
194 194
 
195 195
 	if (!test_espace_prive()) {
@@ -204,23 +204,21 @@  discard block
 block discarded – undo
204 204
 
205 205
 	return generer_action_auteur('converser', $base, $cible,
206 206
 		(select_langues($nom_select, $change, $ret)
207
-			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
207
+			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='"._T('bouton_changer')."' /></div></noscript>"),
208 208
 		" method='post'");
209 209
 }
210 210
 
211 211
 // https://code.spip.net/@select_langues
212 212
 function select_langues($nom_select, $change, $options, $label = "") {
213 213
 	static $cpt = 0;
214
-	$id = "menu_langues" . $cpt++;
214
+	$id = "menu_langues".$cpt++;
215 215
 
216 216
 	return
217
-		"<label for='$id'>" . ($label ? $label : _T('info_langues')) . "</label> " .
217
+		"<label for='$id'>".($label ? $label : _T('info_langues'))."</label> ".
218 218
 		"<select name='$nom_select' id='$id' "
219 219
 		. ((!test_espace_prive()) ?
220
-			("class='forml menu_langues'") :
221
-			(($nom_select == 'var_lang_ecrire') ?
222
-				("class='lang_ecrire'") :
223
-				"class='fondl'"))
220
+			("class='forml menu_langues'") : (($nom_select == 'var_lang_ecrire') ?
221
+				("class='lang_ecrire'") : "class='fondl'"))
224 222
 		. $change
225 223
 		. ">\n"
226 224
 		. $options
@@ -342,7 +340,7 @@  discard block
 block discarded – undo
342 340
 		and (!isset($GLOBALS['spip_lang'])
343 341
 			or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
344 342
 	) {
345
-		return changer_langue($GLOBALS['meta']['langue_site']);//@:install
343
+		return changer_langue($GLOBALS['meta']['langue_site']); //@:install
346 344
 	}
347 345
 	// en theorie là, la globale est définie, sinon c'est un problème.
348 346
 	if (!isset($GLOBALS['spip_lang'])) {
@@ -443,7 +441,7 @@  discard block
 block discarded – undo
443 441
 	if (!isset($GLOBALS['meta']['langue_site'])) {
444 442
 		// Initialisation : le francais si dispo, sinon la premiere langue trouvee
445 443
 		$GLOBALS['meta']['langue_site'] = $tout =
446
-			(!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', ",$all_langs,") !== false))
444
+			(!$all_langs or (strpos(','._LANGUE_PAR_DEFAUT.',', ",$all_langs,") !== false))
447 445
 				? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ','));
448 446
 		ecrire_meta('langue_site', $tout);
449 447
 	}
Please login to merge, or discard this patch.
ecrire/inc/lien.php 3 patches
Doc Comments   +13 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,6 +42,9 @@  discard block
 block discarded – undo
42 42
 define('_RACCOURCI_LIEN', "/\[([^][]*?([[]\w*[]][^][]*)*)->(>?)([^]]*)\]/msS");
43 43
 
44 44
 // https://code.spip.net/@expanser_liens
45
+/**
46
+ * @return string
47
+ */
45 48
 function expanser_liens($t, $connect = '', $env = array()) {
46 49
 
47 50
 	$t = pipeline('pre_liens', $t);
@@ -56,6 +59,9 @@  discard block
 block discarded – undo
56 59
 // Meme analyse mais pour eliminer les liens
57 60
 // et ne laisser que leur titre, a expliciter si ce n'est fait
58 61
 // https://code.spip.net/@nettoyer_raccourcis_typo
62
+/**
63
+ * @param string $texte
64
+ */
59 65
 function nettoyer_raccourcis_typo($texte, $connect = '') {
60 66
 	return $texte;
61 67
 }
@@ -96,6 +102,9 @@  discard block
 block discarded – undo
96 102
 // 'url':   seulement U  (i.e. generer_url_RACCOURCI)
97 103
 
98 104
 // https://code.spip.net/@calculer_url
105
+/**
106
+ * @return string
107
+ */
99 108
 function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
100 109
 	$r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
101 110
 
@@ -256,7 +265,7 @@  discard block
 block discarded – undo
256 265
  * @param int $id Identifiant de l'objet
257 266
  * @param string $type Type d'objet
258 267
  * @param string|null $connect Connecteur SQL utilisé
259
- * @return array {
268
+ * @return string {
260 269
  * @var string $titre Titre si présent, sinon ''
261 270
  * @var string $lang Langue si présente, sinon ''
262 271
  * }
@@ -302,6 +311,9 @@  discard block
 block discarded – undo
302 311
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
303 312
 
304 313
 // https://code.spip.net/@traiter_modeles
314
+/**
315
+ * @return string
316
+ */
305 317
 function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) {
306 318
 	// preserver la compatibilite : true = recherche des documents
307 319
 	if ($doublons === true) {
Please login to merge, or discard this patch.
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('base/abstract_sql');
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 //
24 24
 
25 25
 function inc_lien_dist(
26
-	$lien,
27
-	$texte = '',
28
-	$class = '',
29
-	$title = '',
30
-	$hlang = '',
31
-	$rel = '',
32
-	$connect = '',
33
-	$env = array()
26
+    $lien,
27
+    $texte = '',
28
+    $class = '',
29
+    $title = '',
30
+    $hlang = '',
31
+    $rel = '',
32
+    $connect = '',
33
+    $env = array()
34 34
 ) {
35
-	return $lien;
35
+    return $lien;
36 36
 }
37 37
 
38 38
 // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 // https://code.spip.net/@expanser_liens
45 45
 function expanser_liens($t, $connect = '', $env = array()) {
46 46
 
47
-	$t = pipeline('pre_liens', $t);
47
+    $t = pipeline('pre_liens', $t);
48 48
 
49
-	// on passe a traiter_modeles la liste des liens reperes pour lui permettre
50
-	// de remettre le texte d'origine dans les parametres du modele
51
-	$t = traiter_modeles($t, false, false, $connect);
49
+    // on passe a traiter_modeles la liste des liens reperes pour lui permettre
50
+    // de remettre le texte d'origine dans les parametres du modele
51
+    $t = traiter_modeles($t, false, false, $connect);
52 52
 
53
-	return $t;
53
+    return $t;
54 54
 }
55 55
 
56 56
 // Meme analyse mais pour eliminer les liens
57 57
 // et ne laisser que leur titre, a expliciter si ce n'est fait
58 58
 // https://code.spip.net/@nettoyer_raccourcis_typo
59 59
 function nettoyer_raccourcis_typo($texte, $connect = '') {
60
-	return $texte;
60
+    return $texte;
61 61
 }
62 62
 
63 63
 // Repere dans la partie texte d'un raccourci [texte->...]
64 64
 // la langue et la bulle eventuelles
65 65
 // https://code.spip.net/@traiter_raccourci_lien_atts
66 66
 function traiter_raccourci_lien_atts($texte) {
67
-	$bulle = '';
68
-	$hlang = '';
67
+    $bulle = '';
68
+    $hlang = '';
69 69
 
70
-	return array(trim($texte), $bulle, $hlang);
70
+    return array(trim($texte), $bulle, $hlang);
71 71
 }
72 72
 
73 73
 define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  * @return string
84 84
  */
85 85
 function virtuel_redirige($virtuel, $url = false) {
86
-	return $virtuel;
86
+    return $virtuel;
87 87
 }
88 88
 
89 89
 // Cherche un lien du type [->raccourci 123]
@@ -97,114 +97,114 @@  discard block
 block discarded – undo
97 97
 
98 98
 // https://code.spip.net/@calculer_url
99 99
 function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
100
-	$r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
100
+    $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
101 101
 
102
-	return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
102
+    return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
103 103
 }
104 104
 
105 105
 define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
106 106
 
107 107
 // https://code.spip.net/@traiter_lien_explicite
108 108
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
109
-	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
110
-		return ($pour != 'tout') ? '' : array('', '', '', '');
111
-	}
112
-
113
-	$lien = entites_html(trim($ref));
114
-
115
-	// Liens explicites
116
-	if (!$texte) {
117
-		$texte = str_replace('"', '', $lien);
118
-		// evite l'affichage de trops longues urls.
119
-		$lien_court = charger_fonction('lien_court', 'inc');
120
-		$texte = $lien_court($texte);
121
-		if ($echappe_typo) {
122
-			$texte = "<html>" . quote_amp($texte) . "</html>";
123
-		}
124
-	}
125
-
126
-	// petites corrections d'URL
127
-	if (preg_match('/^www\.[^@]+$/S', $lien)) {
128
-		$lien = "http://" . $lien;
129
-	} else {
130
-		if (strpos($lien, "@") && email_valide($lien)) {
131
-			if (!$texte) {
132
-				$texte = $lien;
133
-			}
134
-			$lien = "mailto:" . $lien;
135
-		}
136
-	}
137
-
138
-	if ($pour == 'url') {
139
-		return $lien;
140
-	}
141
-
142
-	if ($pour == 'titre') {
143
-		return $texte;
144
-	}
145
-
146
-	return array('url' => $lien, 'titre' => $texte);
109
+    if (preg_match(_EXTRAIRE_LIEN, $ref)) {
110
+        return ($pour != 'tout') ? '' : array('', '', '', '');
111
+    }
112
+
113
+    $lien = entites_html(trim($ref));
114
+
115
+    // Liens explicites
116
+    if (!$texte) {
117
+        $texte = str_replace('"', '', $lien);
118
+        // evite l'affichage de trops longues urls.
119
+        $lien_court = charger_fonction('lien_court', 'inc');
120
+        $texte = $lien_court($texte);
121
+        if ($echappe_typo) {
122
+            $texte = "<html>" . quote_amp($texte) . "</html>";
123
+        }
124
+    }
125
+
126
+    // petites corrections d'URL
127
+    if (preg_match('/^www\.[^@]+$/S', $lien)) {
128
+        $lien = "http://" . $lien;
129
+    } else {
130
+        if (strpos($lien, "@") && email_valide($lien)) {
131
+            if (!$texte) {
132
+                $texte = $lien;
133
+            }
134
+            $lien = "mailto:" . $lien;
135
+        }
136
+    }
137
+
138
+    if ($pour == 'url') {
139
+        return $lien;
140
+    }
141
+
142
+    if ($pour == 'titre') {
143
+        return $texte;
144
+    }
145
+
146
+    return array('url' => $lien, 'titre' => $texte);
147 147
 }
148 148
 
149 149
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') {
150
-	if (function_exists($f = 'glossaire_' . $ancre)) {
151
-		$url = $f($texte, $id);
152
-	} else {
153
-		$url = glossaire_std($texte);
154
-	}
150
+    if (function_exists($f = 'glossaire_' . $ancre)) {
151
+        $url = $f($texte, $id);
152
+    } else {
153
+        $url = glossaire_std($texte);
154
+    }
155 155
 
156
-	return $url;
156
+    return $url;
157 157
 }
158 158
 
159 159
 // https://code.spip.net/@traiter_lien_implicite
160 160
 function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') {
161
-	if (!($match = typer_raccourci($ref))) {
162
-		return false;
163
-	}
164
-	@list($type, , $id, , $args, , $ancre) = $match;
165
-	// attention dans le cas des sites le lien doit pointer non pas sur
166
-	// la page locale du site, mais directement sur le site lui-meme
167
-	if ($f = charger_fonction("implicite_$type", "liens", true)) {
168
-		$url = $f($texte, $id, $type, $args, $ancre, $connect);
169
-	}
170
-	if (!$url) {
171
-		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
172
-	}
173
-	if (!$url) {
174
-		return false;
175
-	}
176
-	if (is_array($url)) {
177
-		@list($type, $id) = $url;
178
-		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
179
-	}
180
-	if ($pour === 'url') {
181
-		return $url;
182
-	}
183
-	$r = traiter_raccourci_titre($id, $type, $connect);
184
-	if ($r) {
185
-		$r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
186
-	}
187
-	if ($texte = trim($texte)) {
188
-		$r['titre'] = $texte;
189
-	}
190
-	if (!@$r['titre']) {
191
-		$r['titre'] = _T($type) . " $id";
192
-	}
193
-	if ($pour == 'titre') {
194
-		return $r['titre'];
195
-	}
196
-	$r['url'] = $url;
197
-
198
-	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
199
-	if ($type == 'document'
200
-		and $mime = sql_getfetsel('mime_type', 'spip_types_documents',
201
-			"extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")",
202
-			'', '', '', '', $connect)
203
-	) {
204
-		$r['mime'] = $mime;
205
-	}
206
-
207
-	return $r;
161
+    if (!($match = typer_raccourci($ref))) {
162
+        return false;
163
+    }
164
+    @list($type, , $id, , $args, , $ancre) = $match;
165
+    // attention dans le cas des sites le lien doit pointer non pas sur
166
+    // la page locale du site, mais directement sur le site lui-meme
167
+    if ($f = charger_fonction("implicite_$type", "liens", true)) {
168
+        $url = $f($texte, $id, $type, $args, $ancre, $connect);
169
+    }
170
+    if (!$url) {
171
+        $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
172
+    }
173
+    if (!$url) {
174
+        return false;
175
+    }
176
+    if (is_array($url)) {
177
+        @list($type, $id) = $url;
178
+        $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
179
+    }
180
+    if ($pour === 'url') {
181
+        return $url;
182
+    }
183
+    $r = traiter_raccourci_titre($id, $type, $connect);
184
+    if ($r) {
185
+        $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
186
+    }
187
+    if ($texte = trim($texte)) {
188
+        $r['titre'] = $texte;
189
+    }
190
+    if (!@$r['titre']) {
191
+        $r['titre'] = _T($type) . " $id";
192
+    }
193
+    if ($pour == 'titre') {
194
+        return $r['titre'];
195
+    }
196
+    $r['url'] = $url;
197
+
198
+    // dans le cas d'un lien vers un doc, ajouter le type='mime/type'
199
+    if ($type == 'document'
200
+        and $mime = sql_getfetsel('mime_type', 'spip_types_documents',
201
+            "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")",
202
+            '', '', '', '', $connect)
203
+    ) {
204
+        $r['mime'] = $mime;
205
+    }
206
+
207
+    return $r;
208 208
 }
209 209
 
210 210
 // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes
@@ -213,41 +213,41 @@  discard block
 block discarded – undo
213 213
 
214 214
 // https://code.spip.net/@typer_raccourci
215 215
 function typer_raccourci($lien) {
216
-	if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
217
-		return array();
218
-	}
219
-	$f = $match[1];
220
-	// valeur par defaut et alias historiques
221
-	if (!$f) {
222
-		$f = 'article';
223
-	} else {
224
-		if ($f == 'art') {
225
-			$f = 'article';
226
-		} else {
227
-			if ($f == 'br') {
228
-				$f = 'breve';
229
-			} else {
230
-				if ($f == 'rub') {
231
-					$f = 'rubrique';
232
-				} else {
233
-					if ($f == 'aut') {
234
-						$f = 'auteur';
235
-					} else {
236
-						if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
237
-							$f = 'document';
238
-						} else {
239
-							if (preg_match('/^br..?ve$/S', $f)) {
240
-								$f = 'breve';
241
-							}
242
-						}
243
-					}
244
-				}
245
-			}
246
-		}
247
-	} # accents :(
248
-	$match[0] = $f;
249
-
250
-	return $match;
216
+    if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
217
+        return array();
218
+    }
219
+    $f = $match[1];
220
+    // valeur par defaut et alias historiques
221
+    if (!$f) {
222
+        $f = 'article';
223
+    } else {
224
+        if ($f == 'art') {
225
+            $f = 'article';
226
+        } else {
227
+            if ($f == 'br') {
228
+                $f = 'breve';
229
+            } else {
230
+                if ($f == 'rub') {
231
+                    $f = 'rubrique';
232
+                } else {
233
+                    if ($f == 'aut') {
234
+                        $f = 'auteur';
235
+                    } else {
236
+                        if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
237
+                            $f = 'document';
238
+                        } else {
239
+                            if (preg_match('/^br..?ve$/S', $f)) {
240
+                                $f = 'breve';
241
+                            }
242
+                        }
243
+                    }
244
+                }
245
+            }
246
+        }
247
+    } # accents :(
248
+    $match[0] = $f;
249
+
250
+    return $match;
251 251
 }
252 252
 
253 253
 /**
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
  * }
263 263
  **/
264 264
 function traiter_raccourci_titre($id, $type, $connect = null) {
265
-	$trouver_table = charger_fonction('trouver_table', 'base');
266
-	$desc = $trouver_table(table_objet($type));
267
-	if (!($desc and $s = $desc['titre'])) {
268
-		return array();
269
-	}
270
-	$_id = $desc['key']['PRIMARY KEY'];
271
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
272
-	if (!$r) {
273
-		return array();
274
-	}
275
-	$r['titre'] = supprimer_numero($r['titre']);
276
-	if (!$r['titre'] and !empty($r['surnom'])) {
277
-		$r['titre'] = $r['surnom'];
278
-	}
279
-	if (!isset($r['lang'])) {
280
-		$r['lang'] = '';
281
-	}
282
-
283
-	return $r;
265
+    $trouver_table = charger_fonction('trouver_table', 'base');
266
+    $desc = $trouver_table(table_objet($type));
267
+    if (!($desc and $s = $desc['titre'])) {
268
+        return array();
269
+    }
270
+    $_id = $desc['key']['PRIMARY KEY'];
271
+    $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
272
+    if (!$r) {
273
+        return array();
274
+    }
275
+    $r['titre'] = supprimer_numero($r['titre']);
276
+    if (!$r['titre'] and !empty($r['surnom'])) {
277
+        $r['titre'] = $r['surnom'];
278
+    }
279
+    if (!isset($r['lang'])) {
280
+        $r['lang'] = '';
281
+    }
282
+
283
+    return $r;
284 284
 }
285 285
 
286 286
 // traite les modeles (dans la fonction typo), en remplacant
@@ -292,115 +292,115 @@  discard block
 block discarded – undo
292 292
 // https://code.spip.net/@traiter_modeles
293 293
 
294 294
 define('_RACCOURCI_MODELE',
295
-	'(<([a-z_-]{3,})' # <modele
296
-	. '\s*([0-9]*)\s*' # id
297
-	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
298
-	. '\s*/?' . '>)' # fin du modele >
299
-	. '\s*(<\/a>)?' # eventuel </a>
295
+    '(<([a-z_-]{3,})' # <modele
296
+    . '\s*([0-9]*)\s*' # id
297
+    . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
298
+    . '\s*/?' . '>)' # fin du modele >
299
+    . '\s*(<\/a>)?' # eventuel </a>
300 300
 );
301 301
 
302 302
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
303 303
 
304 304
 // https://code.spip.net/@traiter_modeles
305 305
 function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) {
306
-	// preserver la compatibilite : true = recherche des documents
307
-	if ($doublons === true) {
308
-		$doublons = array('documents' => array('doc', 'emb', 'img'));
309
-	}
310
-	// detecter les modeles (rapide)
311
-	if (strpos($texte, "<") !== false and
312
-		preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
313
-	) {
314
-		include_spip('public/assembler');
315
-		$wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true);
316
-		foreach ($matches as $match) {
317
-			// Recuperer l'appel complet (y compris un eventuel lien)
318
-
319
-			$a = strpos($texte, $match[0]);
320
-			preg_match(_RACCOURCI_MODELE_DEBUT,
321
-				substr($texte, $a), $regs);
322
-			$regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
323
-			list(, $mod, $type, $id, $params, $fin) = $regs;
324
-			if ($fin and
325
-				preg_match('/<a\s[^<>]*>\s*$/i',
326
-					substr($texte, 0, $a), $r)
327
-			) {
328
-				$lien = array(
329
-					'href' => extraire_attribut($r[0], 'href'),
330
-					'class' => extraire_attribut($r[0], 'class'),
331
-					'mime' => extraire_attribut($r[0], 'type'),
332
-					'title' => extraire_attribut($r[0], 'title'),
333
-					'hreflang' => extraire_attribut($r[0], 'hreflang')
334
-				);
335
-				$n = strlen($r[0]);
336
-				$a -= $n;
337
-				$cherche = $n + strlen($regs[0]);
338
-			} else {
339
-				$lien = false;
340
-				$cherche = strlen($mod);
341
-			}
342
-
343
-			// calculer le modele
344
-			# hack indexation
345
-			if ($doublons) {
346
-				$texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
347
-			} # version normale
348
-			else {
349
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
350
-				// dans les parametres, plutot que les liens echappes
351
-				if (!is_null($liens)) {
352
-					$params = str_replace($liens[0], $liens[1], $params);
353
-				}
354
-				$modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
355
-				// en cas d'echec, 
356
-				// si l'objet demande a une url, 
357
-				// creer un petit encadre vers elle
358
-				if ($modele === false) {
359
-					if (!$lien) {
360
-						$lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
361
-					}
362
-					if ($lien) {
363
-						$modele = '<a href="'
364
-							. $lien['url']
365
-							. '" class="spip_modele'
366
-							. '">'
367
-							. sinon($lien['titre'], _T('ecrire:info_sans_titre'))
368
-							. "</a>";
369
-					} else {
370
-						$modele = "";
371
-						if (test_espace_prive()) {
372
-							$modele = entites_html(substr($texte, $a, $cherche));
373
-							if (!is_null($liens)) {
374
-								$modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>";
375
-							}
376
-						}
377
-					}
378
-				}
379
-				// le remplacer dans le texte
380
-				if ($modele !== false) {
381
-					$modele = protege_js_modeles($modele);
382
-					if ($wrap_embed_html) {
383
-						$modele = $wrap_embed_html($mod, $modele);
384
-					}
385
-					$rempl = code_echappement($modele, $echap);
386
-					$texte = substr($texte, 0, $a)
387
-						. $rempl
388
-						. substr($texte, $a + $cherche);
389
-				}
390
-			}
391
-
392
-			// hack pour tout l'espace prive
393
-			if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
394
-				foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) {
395
-					if (in_array($type, $modeles)) {
396
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
397
-					}
398
-				}
399
-			}
400
-		}
401
-	}
402
-
403
-	return $texte;
306
+    // preserver la compatibilite : true = recherche des documents
307
+    if ($doublons === true) {
308
+        $doublons = array('documents' => array('doc', 'emb', 'img'));
309
+    }
310
+    // detecter les modeles (rapide)
311
+    if (strpos($texte, "<") !== false and
312
+        preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
313
+    ) {
314
+        include_spip('public/assembler');
315
+        $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true);
316
+        foreach ($matches as $match) {
317
+            // Recuperer l'appel complet (y compris un eventuel lien)
318
+
319
+            $a = strpos($texte, $match[0]);
320
+            preg_match(_RACCOURCI_MODELE_DEBUT,
321
+                substr($texte, $a), $regs);
322
+            $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
323
+            list(, $mod, $type, $id, $params, $fin) = $regs;
324
+            if ($fin and
325
+                preg_match('/<a\s[^<>]*>\s*$/i',
326
+                    substr($texte, 0, $a), $r)
327
+            ) {
328
+                $lien = array(
329
+                    'href' => extraire_attribut($r[0], 'href'),
330
+                    'class' => extraire_attribut($r[0], 'class'),
331
+                    'mime' => extraire_attribut($r[0], 'type'),
332
+                    'title' => extraire_attribut($r[0], 'title'),
333
+                    'hreflang' => extraire_attribut($r[0], 'hreflang')
334
+                );
335
+                $n = strlen($r[0]);
336
+                $a -= $n;
337
+                $cherche = $n + strlen($regs[0]);
338
+            } else {
339
+                $lien = false;
340
+                $cherche = strlen($mod);
341
+            }
342
+
343
+            // calculer le modele
344
+            # hack indexation
345
+            if ($doublons) {
346
+                $texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
347
+            } # version normale
348
+            else {
349
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
350
+                // dans les parametres, plutot que les liens echappes
351
+                if (!is_null($liens)) {
352
+                    $params = str_replace($liens[0], $liens[1], $params);
353
+                }
354
+                $modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
355
+                // en cas d'echec, 
356
+                // si l'objet demande a une url, 
357
+                // creer un petit encadre vers elle
358
+                if ($modele === false) {
359
+                    if (!$lien) {
360
+                        $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
361
+                    }
362
+                    if ($lien) {
363
+                        $modele = '<a href="'
364
+                            . $lien['url']
365
+                            . '" class="spip_modele'
366
+                            . '">'
367
+                            . sinon($lien['titre'], _T('ecrire:info_sans_titre'))
368
+                            . "</a>";
369
+                    } else {
370
+                        $modele = "";
371
+                        if (test_espace_prive()) {
372
+                            $modele = entites_html(substr($texte, $a, $cherche));
373
+                            if (!is_null($liens)) {
374
+                                $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>";
375
+                            }
376
+                        }
377
+                    }
378
+                }
379
+                // le remplacer dans le texte
380
+                if ($modele !== false) {
381
+                    $modele = protege_js_modeles($modele);
382
+                    if ($wrap_embed_html) {
383
+                        $modele = $wrap_embed_html($mod, $modele);
384
+                    }
385
+                    $rempl = code_echappement($modele, $echap);
386
+                    $texte = substr($texte, 0, $a)
387
+                        . $rempl
388
+                        . substr($texte, $a + $cherche);
389
+                }
390
+            }
391
+
392
+            // hack pour tout l'espace prive
393
+            if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
394
+                foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) {
395
+                    if (in_array($type, $modeles)) {
396
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $id;
397
+                    }
398
+                }
399
+            }
400
+        }
401
+    }
402
+
403
+    return $texte;
404 404
 }
405 405
 
406 406
 //
@@ -408,15 +408,15 @@  discard block
 block discarded – undo
408 408
 //
409 409
 // https://code.spip.net/@traiter_raccourci_ancre
410 410
 function traiter_raccourci_ancre($letexte) {
411
-	return $letexte;
411
+    return $letexte;
412 412
 }
413 413
 
414 414
 // https://code.spip.net/@traiter_raccourci_glossaire
415 415
 function traiter_raccourci_glossaire($texte) {
416
-	return $texte;
416
+    return $texte;
417 417
 }
418 418
 
419 419
 // https://code.spip.net/@glossaire_std
420 420
 function glossaire_std($terme) {
421
-	return $terme;
421
+    return $terme;
422 422
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
103 103
 }
104 104
 
105
-define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
105
+define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS');
106 106
 
107 107
 // https://code.spip.net/@traiter_lien_explicite
108 108
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 		$lien_court = charger_fonction('lien_court', 'inc');
120 120
 		$texte = $lien_court($texte);
121 121
 		if ($echappe_typo) {
122
-			$texte = "<html>" . quote_amp($texte) . "</html>";
122
+			$texte = "<html>".quote_amp($texte)."</html>";
123 123
 		}
124 124
 	}
125 125
 
126 126
 	// petites corrections d'URL
127 127
 	if (preg_match('/^www\.[^@]+$/S', $lien)) {
128
-		$lien = "http://" . $lien;
128
+		$lien = "http://".$lien;
129 129
 	} else {
130 130
 		if (strpos($lien, "@") && email_valide($lien)) {
131 131
 			if (!$texte) {
132 132
 				$texte = $lien;
133 133
 			}
134
-			$lien = "mailto:" . $lien;
134
+			$lien = "mailto:".$lien;
135 135
 		}
136 136
 	}
137 137
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 }
148 148
 
149 149
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') {
150
-	if (function_exists($f = 'glossaire_' . $ancre)) {
150
+	if (function_exists($f = 'glossaire_'.$ancre)) {
151 151
 		$url = $f($texte, $id);
152 152
 	} else {
153 153
 		$url = glossaire_std($texte);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if (!($match = typer_raccourci($ref))) {
162 162
 		return false;
163 163
 	}
164
-	@list($type, , $id, , $args, , $ancre) = $match;
164
+	@list($type,, $id,, $args,, $ancre) = $match;
165 165
 	// attention dans le cas des sites le lien doit pointer non pas sur
166 166
 	// la page locale du site, mais directement sur le site lui-meme
167 167
 	if ($f = charger_fonction("implicite_$type", "liens", true)) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$r['titre'] = $texte;
189 189
 	}
190 190
 	if (!@$r['titre']) {
191
-		$r['titre'] = _T($type) . " $id";
191
+		$r['titre'] = _T($type)." $id";
192 192
 	}
193 193
 	if ($pour == 'titre') {
194 194
 		return $r['titre'];
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
199 199
 	if ($type == 'document'
200 200
 		and $mime = sql_getfetsel('mime_type', 'spip_types_documents',
201
-			"extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")",
201
+			"extension IN (".sql_get_select("extension", "spip_documents", "id_document=".sql_quote($id)).")",
202 202
 			'', '', '', '', $connect)
203 203
 	) {
204 204
 		$r['mime'] = $mime;
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
 	'(<([a-z_-]{3,})' # <modele
296 296
 	. '\s*([0-9]*)\s*' # id
297 297
 	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
298
-	. '\s*/?' . '>)' # fin du modele >
298
+	. '\s*/?'.'>)' # fin du modele >
299 299
 	. '\s*(<\/a>)?' # eventuel </a>
300 300
 );
301 301
 
302
-define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
302
+define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS');
303 303
 
304 304
 // https://code.spip.net/@traiter_modeles
305 305
 function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) {
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 						if (test_espace_prive()) {
372 372
 							$modele = entites_html(substr($texte, $a, $cherche));
373 373
 							if (!is_null($liens)) {
374
-								$modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>";
374
+								$modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>";
375 375
 							}
376 376
 						}
377 377
 					}
Please login to merge, or discard this patch.
ecrire/inc/math.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
 //
22 22
 
23 23
 // https://code.spip.net/@image_math
24
+/**
25
+ * @param string $tex
26
+ */
24 27
 function produire_image_math($tex) {
25 28
 
26 29
 	switch ($GLOBALS['traiter_math']) {
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 //
15 15
 if (!defined('_ECRIRE_INC_VERSION')) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 //
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
 // https://code.spip.net/@image_math
24 24
 function produire_image_math($tex) {
25 25
 
26
-	switch ($GLOBALS['traiter_math']) {
27
-		// Attention: mathml desactiv'e pour l'instant
28
-		case 'mathml':
29
-			$ext = '.xhtml';
30
-			$server = $GLOBALS['mathml_server'];
31
-			break;
32
-		case 'tex':
33
-			$ext = '.png';
34
-			$server = $GLOBALS['tex_server'];
35
-			break;
36
-		default:
37
-			return $tex;
38
-	}
39
-
40
-	// Regarder dans le repertoire local des images TeX et blocs MathML
41
-	if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
42
-		@mkdir($dir_tex, _SPIP_CHMOD);
43
-	}
44
-	$fichier = $dir_tex . md5(trim($tex)) . $ext;
45
-
46
-
47
-	if (!@file_exists($fichier)) {
48
-		// Aller chercher l'image sur le serveur
49
-		if ($server) {
50
-			spip_log($url = $server . '?' . rawurlencode($tex));
51
-			include_spip('inc/distant');
52
-			recuperer_page($url, $fichier);
53
-		}
54
-	}
55
-
56
-
57
-	// Composer la reponse selon presence ou non de l'image
58
-	$tex = entites_html($tex);
59
-	if (@file_exists($fichier)) {
60
-
61
-		// MathML
62
-		if ($GLOBALS['traiter_math'] == 'mathml') {
63
-			return join(file("$fichier"), "");
64
-		} // TeX
65
-		else {
66
-			list(, , , $size) = @spip_getimagesize($fichier);
67
-			$alt = "alt=\"$tex\" title=\"$tex\"";
68
-
69
-			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
70
-		}
71
-
72
-	} else // pas de fichier
73
-	{
74
-		return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
75
-	}
26
+    switch ($GLOBALS['traiter_math']) {
27
+        // Attention: mathml desactiv'e pour l'instant
28
+        case 'mathml':
29
+            $ext = '.xhtml';
30
+            $server = $GLOBALS['mathml_server'];
31
+            break;
32
+        case 'tex':
33
+            $ext = '.png';
34
+            $server = $GLOBALS['tex_server'];
35
+            break;
36
+        default:
37
+            return $tex;
38
+    }
39
+
40
+    // Regarder dans le repertoire local des images TeX et blocs MathML
41
+    if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
42
+        @mkdir($dir_tex, _SPIP_CHMOD);
43
+    }
44
+    $fichier = $dir_tex . md5(trim($tex)) . $ext;
45
+
46
+
47
+    if (!@file_exists($fichier)) {
48
+        // Aller chercher l'image sur le serveur
49
+        if ($server) {
50
+            spip_log($url = $server . '?' . rawurlencode($tex));
51
+            include_spip('inc/distant');
52
+            recuperer_page($url, $fichier);
53
+        }
54
+    }
55
+
56
+
57
+    // Composer la reponse selon presence ou non de l'image
58
+    $tex = entites_html($tex);
59
+    if (@file_exists($fichier)) {
60
+
61
+        // MathML
62
+        if ($GLOBALS['traiter_math'] == 'mathml') {
63
+            return join(file("$fichier"), "");
64
+        } // TeX
65
+        else {
66
+            list(, , , $size) = @spip_getimagesize($fichier);
67
+            $alt = "alt=\"$tex\" title=\"$tex\"";
68
+
69
+            return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
70
+        }
71
+
72
+    } else // pas de fichier
73
+    {
74
+        return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
75
+    }
76 76
 
77 77
 }
78 78
 
@@ -108,46 +108,46 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function traiter_math($letexte, $source = '', $defaire_amp = false) {
110 110
 
111
-	$texte_a_voir = $letexte;
112
-	while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
113
-		if (!$fin = strpos($texte_a_voir, "</math>")) {
114
-			$fin = strlen($texte_a_voir);
115
-		}
116
-
117
-		$texte_debut = substr($texte_a_voir, 0, $debut);
118
-		$texte_milieu = substr($texte_a_voir,
119
-			$debut + strlen("<math>"), $fin - $debut - strlen("<math>"));
120
-		$texte_fin = substr($texte_a_voir,
121
-			$fin + strlen("</math>"), strlen($texte_a_voir));
122
-
123
-		// Les doubles $$x^2$$ en mode 'div'
124
-		while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) {
125
-			$expression = $regs[1];
126
-			if ($defaire_amp) {
127
-				$expression = str_replace('&amp;', '&', $expression);
128
-			}
129
-			$echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n";
130
-			$pos = strpos($texte_milieu, $regs[0]);
131
-			$texte_milieu = substr($texte_milieu, 0, $pos)
132
-				. code_echappement($echap, $source)
133
-				. substr($texte_milieu, $pos + strlen($regs[0]));
134
-		}
135
-
136
-		// Les simples $x^2$ en mode 'span'
137
-		while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) {
138
-			$expression = $regs[1];
139
-			if ($defaire_amp) {
140
-				$expression = str_replace('&amp;', '&', $expression);
141
-			}
142
-			$echap = produire_image_math($expression);
143
-			$pos = strpos($texte_milieu, $regs[0]);
144
-			$texte_milieu = substr($texte_milieu, 0, $pos)
145
-				. code_echappement($echap, $source)
146
-				. substr($texte_milieu, $pos + strlen($regs[0]));
147
-		}
148
-
149
-		$texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
150
-	}
151
-
152
-	return $texte_a_voir;
111
+    $texte_a_voir = $letexte;
112
+    while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
113
+        if (!$fin = strpos($texte_a_voir, "</math>")) {
114
+            $fin = strlen($texte_a_voir);
115
+        }
116
+
117
+        $texte_debut = substr($texte_a_voir, 0, $debut);
118
+        $texte_milieu = substr($texte_a_voir,
119
+            $debut + strlen("<math>"), $fin - $debut - strlen("<math>"));
120
+        $texte_fin = substr($texte_a_voir,
121
+            $fin + strlen("</math>"), strlen($texte_a_voir));
122
+
123
+        // Les doubles $$x^2$$ en mode 'div'
124
+        while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) {
125
+            $expression = $regs[1];
126
+            if ($defaire_amp) {
127
+                $expression = str_replace('&amp;', '&', $expression);
128
+            }
129
+            $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n";
130
+            $pos = strpos($texte_milieu, $regs[0]);
131
+            $texte_milieu = substr($texte_milieu, 0, $pos)
132
+                . code_echappement($echap, $source)
133
+                . substr($texte_milieu, $pos + strlen($regs[0]));
134
+        }
135
+
136
+        // Les simples $x^2$ en mode 'span'
137
+        while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) {
138
+            $expression = $regs[1];
139
+            if ($defaire_amp) {
140
+                $expression = str_replace('&amp;', '&', $expression);
141
+            }
142
+            $echap = produire_image_math($expression);
143
+            $pos = strpos($texte_milieu, $regs[0]);
144
+            $texte_milieu = substr($texte_milieu, 0, $pos)
145
+                . code_echappement($echap, $source)
146
+                . substr($texte_milieu, $pos + strlen($regs[0]));
147
+        }
148
+
149
+        $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
150
+    }
151
+
152
+    return $texte_a_voir;
153 153
 }
Please login to merge, or discard this patch.
ecrire/inc/presentation.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 include_spip('inc/filtres_boites');
31 31
 
32 32
 // https://code.spip.net/@debut_cadre
33
+/**
34
+ * @param string $style
35
+ */
33 36
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34 37
 	$style_mapping = array(
35 38
 		'r' => 'simple',
@@ -183,6 +186,10 @@  discard block
 block discarded – undo
183 186
 function fin_onglet() { return "</ul></div>\n"; }
184 187
 
185 188
 // https://code.spip.net/@onglet
189
+/**
190
+ * @param string $texte
191
+ * @param string $onglet
192
+ */
186 193
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187 194
 	return "<li>"
188 195
 	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Presentation
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/presentation_mini');
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
 // https://code.spip.net/@debut_cadre
33 33
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34
-	$style_mapping = array(
35
-		'r' => 'simple',
36
-		'e' => 'raccourcis',
37
-		'couleur' => 'basic highlight',
38
-		'couleur-foncee' => 'basic highlight',
39
-		'trait-couleur' => 'important',
40
-		'alerte' => 'notice',
41
-		'info' => 'info',
42
-		'sous_rub' => 'simple sous-rub'
43
-	);
44
-	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
-	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
47
-	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
49
-	}
50
-
51
-	//($id?"id='$id' ":"")
52
-	if (strlen($icone) > 1) {
53
-		if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
-			list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
-		}
56
-		$size = 24;
57
-		if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
-			$size = $match[1];
59
-		}
60
-		if ($fonction) {
61
-			// 2 images pour composer l'icone : le fond (article) en background,
62
-			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
-				http_style_background($fond, "no-repeat center center", $size));
65
-		} else {
66
-			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
-		}
68
-		$titre = $icone . $titre;
69
-	}
70
-
71
-	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
34
+    $style_mapping = array(
35
+        'r' => 'simple',
36
+        'e' => 'raccourcis',
37
+        'couleur' => 'basic highlight',
38
+        'couleur-foncee' => 'basic highlight',
39
+        'trait-couleur' => 'important',
40
+        'alerte' => 'notice',
41
+        'info' => 'info',
42
+        'sous_rub' => 'simple sous-rub'
43
+    );
44
+    $style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
+    $c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
+    $class = $c . ($class ? " $class" : "");
47
+    if (!$padding) {
48
+        $class .= ($class ? " " : "") . "no-padding";
49
+    }
50
+
51
+    //($id?"id='$id' ":"")
52
+    if (strlen($icone) > 1) {
53
+        if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
+            list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
+        }
56
+        $size = 24;
57
+        if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
+            $size = $match[1];
59
+        }
60
+        if ($fonction) {
61
+            // 2 images pour composer l'icone : le fond (article) en background,
62
+            // la fonction (new) en image
63
+            $icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
+                http_style_background($fond, "no-repeat center center", $size));
65
+        } else {
66
+            $icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
+        }
68
+        $titre = $icone . $titre;
69
+    }
70
+
71
+    return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
72 72
 }
73 73
 
74 74
 // https://code.spip.net/@fin_cadre
@@ -76,66 +76,66 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
 function debut_cadre_relief(
79
-	$icone = '',
80
-	$dummy = '',
81
-	$fonction = '',
82
-	$titre = '',
83
-	$id = "",
84
-	$class = ""
79
+    $icone = '',
80
+    $dummy = '',
81
+    $fonction = '',
82
+    $titre = '',
83
+    $id = "",
84
+    $class = ""
85 85
 ) {
86
-	return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
86
+    return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
87 87
 }
88 88
 
89 89
 function fin_cadre_relief() { return fin_cadre('r'); }
90 90
 
91 91
 function debut_cadre_enfonce(
92
-	$icone = '',
93
-	$dummy = '',
94
-	$fonction = '',
95
-	$titre = '',
96
-	$id = "",
97
-	$class = ""
92
+    $icone = '',
93
+    $dummy = '',
94
+    $fonction = '',
95
+    $titre = '',
96
+    $id = "",
97
+    $class = ""
98 98
 ) {
99
-	return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
99
+    return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
100 100
 }
101 101
 
102 102
 function fin_cadre_enfonce() { return fin_cadre('e'); }
103 103
 
104 104
 function debut_cadre_sous_rub(
105
-	$icone = '',
106
-	$dummy = '',
107
-	$fonction = '',
108
-	$titre = '',
109
-	$id = "",
110
-	$class = ""
105
+    $icone = '',
106
+    $dummy = '',
107
+    $fonction = '',
108
+    $titre = '',
109
+    $id = "",
110
+    $class = ""
111 111
 ) {
112
-	return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
112
+    return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
113 113
 }
114 114
 
115 115
 function fin_cadre_sous_rub() { return fin_cadre('sous_rub'); }
116 116
 
117 117
 function debut_cadre_couleur(
118
-	$icone = '',
119
-	$dummy = '',
120
-	$fonction = '',
121
-	$titre = '',
122
-	$id = "",
123
-	$class = ""
118
+    $icone = '',
119
+    $dummy = '',
120
+    $fonction = '',
121
+    $titre = '',
122
+    $id = "",
123
+    $class = ""
124 124
 ) {
125
-	return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
125
+    return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
126 126
 }
127 127
 
128 128
 function fin_cadre_couleur() { return fin_cadre('couleur'); }
129 129
 
130 130
 function debut_cadre_trait_couleur(
131
-	$icone = '',
132
-	$dummy = '',
133
-	$fonction = '',
134
-	$titre = '',
135
-	$id = "",
136
-	$class = ""
131
+    $icone = '',
132
+    $dummy = '',
133
+    $fonction = '',
134
+    $titre = '',
135
+    $id = "",
136
+    $class = ""
137 137
 ) {
138
-	return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
138
+    return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
139 139
 }
140 140
 
141 141
 function fin_cadre_trait_couleur() { return fin_cadre('trait-couleur'); }
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
  * @return string Code PHP.
157 157
  **/
158 158
 function gros_titre(
159
-	$titre,
160
-	$ze_logo = ''
159
+    $titre,
160
+    $ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+    return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
166 166
 // Se place a droite si l'ecran est en mode panoramique.
167 167
 // https://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169
-	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
169
+    return creer_colonne_droite()
170
+    . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
171 171
 }
172 172
 
173 173
 //
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 
185 185
 // https://code.spip.net/@onglet
186 186
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187
-	return "<li>"
188
-	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
-	. lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
-	. "</li>";
187
+    return "<li>"
188
+    . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
+    . lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
+    . "</li>";
191 191
 }
192 192
 
193 193
 /**
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
  *     Code HTML du lien
220 220
  **/
221 221
 function icone_verticale($texte, $lien, $fond, $fonction = "", $align = "", $javascript = "") {
222
-	// cas d'ajax_action_auteur: faut defaire le boulot
223
-	// (il faudrait fusionner avec le cas $javascript)
224
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
-		list($x, $lien, $atts, $texte) = $r;
226
-		$javascript .= $atts;
227
-	}
228
-
229
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
222
+    // cas d'ajax_action_auteur: faut defaire le boulot
223
+    // (il faudrait fusionner avec le cas $javascript)
224
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
+        list($x, $lien, $atts, $texte) = $r;
226
+        $javascript .= $atts;
227
+    }
228
+
229
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
230 230
 }
231 231
 
232 232
 /**
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
  *     Code HTML du lien
252 252
  **/
253 253
 function icone_horizontale($texte, $lien, $fond, $fonction = "", $dummy = "", $javascript = "") {
254
-	$retour = '';
255
-	// cas d'ajax_action_auteur: faut defaire le boulot
256
-	// (il faudrait fusionner avec le cas $javascript)
257
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
-		list($x, $lien, $atts, $texte) = $r;
259
-		$javascript .= $atts;
260
-	}
254
+    $retour = '';
255
+    // cas d'ajax_action_auteur: faut defaire le boulot
256
+    // (il faudrait fusionner avec le cas $javascript)
257
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
+        list($x, $lien, $atts, $texte) = $r;
259
+        $javascript .= $atts;
260
+    }
261 261
 
262
-	$retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
262
+    $retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
263 263
 
264
-	return $retour;
264
+    return $retour;
265 265
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	);
44 44
 	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45 45
 	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
46
+	$class = $c.($class ? " $class" : "");
47 47
 	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
48
+		$class .= ($class ? " " : "")."no-padding";
49 49
 	}
50 50
 
51 51
 	//($id?"id='$id' ":"")
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 		if ($fonction) {
61 61
 			// 2 images pour composer l'icone : le fond (article) en background,
62 62
 			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
63
+			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n".
64 64
 				http_style_background($fond, "no-repeat center center", $size));
65 65
 		} else {
66 66
 			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67 67
 		}
68
-		$titre = $icone . $titre;
68
+		$titre = $icone.$titre;
69 69
 	}
70 70
 
71 71
 	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	$titre,
160 160
 	$ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+	return "<h1 class = 'grostitre'>".$ze_logo.' '.typo($titre)."</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 // https://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169 169
 	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
170
+	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis').$bloc.boite_fermer();
171 171
 }
172 172
 
173 173
 //
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -78,6 +78,9 @@  discard block
 block discarded – undo
78 78
 // une $source differente ; le script detecte automagiquement si ce qu'on
79 79
 // echappe est un div ou un span
80 80
 // https://code.spip.net/@code_echappement
81
+/**
82
+ * @param string $mode
83
+ */
81 84
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82 85
 	if (!strlen($rempl)) {
83 86
 		return '';
@@ -282,6 +285,9 @@  discard block
 block discarded – undo
282 285
 // Reinserer le javascript de confiance (venant des modeles)
283 286
 
284 287
 // https://code.spip.net/@echappe_retour_modeles
288
+/**
289
+ * @param string $letexte
290
+ */
285 291
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
286 292
 	$letexte = echappe_retour($letexte);
287 293
 
@@ -427,6 +433,9 @@  discard block
 block discarded – undo
427 433
 }
428 434
 
429 435
 
436
+/**
437
+ * @param string $letexte
438
+ */
430 439
 function echapper_faux_tags($letexte) {
431 440
 	if (strpos($letexte, '<') === false) {
432 441
 		return $letexte;
Please login to merge, or discard this patch.
Indentation   +357 added lines, -357 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
 include_spip('inc/filtres');
23 23
 include_spip('inc/lang');
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function definir_puce() {
41 41
 
42
-	// Attention au sens, qui n'est pas defini de la meme facon dans
43
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
-	// celle du texte) et public (spip_lang est la langue du texte)
45
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
42
+    // Attention au sens, qui n'est pas defini de la meme facon dans
43
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
+    // celle du texte) et public (spip_lang est la langue du texte)
45
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
-	if ($dir == 'rtl') {
49
-		$p .= '_rtl';
50
-	}
47
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
+    if ($dir == 'rtl') {
49
+        $p .= '_rtl';
50
+    }
51 51
 
52
-	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54
-	}
52
+    if (!isset($GLOBALS[$p])) {
53
+        $GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54
+    }
55 55
 
56
-	return $GLOBALS[$p];
56
+    return $GLOBALS[$p];
57 57
 }
58 58
 
59 59
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 // dont on souhaite qu'ils provoquent un saut de paragraphe
62 62
 
63 63
 if (!defined('_BALISES_BLOCS')) {
64
-	define('_BALISES_BLOCS',
65
-	'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
66
-	);
64
+    define('_BALISES_BLOCS',
65
+    'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
66
+    );
67 67
 }
68 68
 
69 69
 if (!defined('_BALISES_BLOCS_REGEXP')) {
70
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
70
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71 71
 }
72 72
 
73 73
 //
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
 // echappe est un div ou un span
80 80
 // https://code.spip.net/@code_echappement
81 81
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82
-	if (!strlen($rempl)) {
83
-		return '';
84
-	}
85
-
86
-	// Tester si on echappe en span ou en div
87
-	if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
-	}
90
-
91
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
-	$taille = 30000;
93
-	$return = "";
94
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
-		// Convertir en base64 et cacher dans un attribut
96
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
97
-		$base64 = base64_encode(substr($rempl, $i, $taille));
98
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
-	}
100
-
101
-	return $return;
82
+    if (!strlen($rempl)) {
83
+        return '';
84
+    }
85
+
86
+    // Tester si on echappe en span ou en div
87
+    if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
+    }
90
+
91
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
+    $taille = 30000;
93
+    $return = "";
94
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
+        // Convertir en base64 et cacher dans un attribut
96
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
97
+        $base64 = base64_encode(substr($rempl, $i, $taille));
98
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
+    }
100
+
101
+    return $return;
102 102
 
103 103
 }
104 104
 
@@ -106,64 +106,64 @@  discard block
 block discarded – undo
106 106
 // Echapper les <html>...</ html>
107 107
 // https://code.spip.net/@traiter_echap_html_dist
108 108
 function traiter_echap_html_dist($regs) {
109
-	return $regs[3];
109
+    return $regs[3];
110 110
 }
111 111
 
112 112
 // Echapper les <code>...</ code>
113 113
 // https://code.spip.net/@traiter_echap_code_dist
114 114
 function traiter_echap_code_dist($regs) {
115
-	list(, , $att, $corps) = $regs;
116
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
117
-
118
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
119
-	if (is_int(strpos($echap, "\n"))) {
120
-		// supprimer les sauts de ligne debut/fin
121
-		// (mais pas les espaces => ascii art).
122
-		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap);
123
-		$echap = nl2br($echap);
124
-		$echap = "<div style='text-align: left;' "
125
-			. "class='spip_code' dir='ltr'><code$att>"
126
-			. $echap . "</code></div>";
127
-	} else {
128
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
129
-	}
130
-
131
-	$echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
132
-	$echap = str_replace("  ", " &nbsp;", $echap);
133
-
134
-	return $echap;
115
+    list(, , $att, $corps) = $regs;
116
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
117
+
118
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
119
+    if (is_int(strpos($echap, "\n"))) {
120
+        // supprimer les sauts de ligne debut/fin
121
+        // (mais pas les espaces => ascii art).
122
+        $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap);
123
+        $echap = nl2br($echap);
124
+        $echap = "<div style='text-align: left;' "
125
+            . "class='spip_code' dir='ltr'><code$att>"
126
+            . $echap . "</code></div>";
127
+    } else {
128
+        $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
129
+    }
130
+
131
+    $echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
132
+    $echap = str_replace("  ", " &nbsp;", $echap);
133
+
134
+    return $echap;
135 135
 }
136 136
 
137 137
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
138 138
 // https://code.spip.net/@traiter_echap_cadre_dist
139 139
 function traiter_echap_cadre_dist($regs) {
140
-	$echap = trim(entites_html($regs[3]));
141
-	// compter les lignes un peu plus finement qu'avec les \n
142
-	$lignes = explode("\n", trim($echap));
143
-	$n = 0;
144
-	foreach ($lignes as $l) {
145
-		$n += floor(strlen($l) / 60) + 1;
146
-	}
147
-	$n = max($n, 2);
148
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
149
-
150
-	return $echap;
140
+    $echap = trim(entites_html($regs[3]));
141
+    // compter les lignes un peu plus finement qu'avec les \n
142
+    $lignes = explode("\n", trim($echap));
143
+    $n = 0;
144
+    foreach ($lignes as $l) {
145
+        $n += floor(strlen($l) / 60) + 1;
146
+    }
147
+    $n = max($n, 2);
148
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
149
+
150
+    return $echap;
151 151
 }
152 152
 
153 153
 // https://code.spip.net/@traiter_echap_frame_dist
154 154
 function traiter_echap_frame_dist($regs) {
155
-	return traiter_echap_cadre_dist($regs);
155
+    return traiter_echap_cadre_dist($regs);
156 156
 }
157 157
 
158 158
 // https://code.spip.net/@traiter_echap_script_dist
159 159
 function traiter_echap_script_dist($regs) {
160
-	// rendre joli (et inactif) si c'est un script language=php
161
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
162
-		return highlight_string($regs[0], true);
163
-	}
160
+    // rendre joli (et inactif) si c'est un script language=php
161
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
162
+        return highlight_string($regs[0], true);
163
+    }
164 164
 
165
-	// Cas normal : le script passe tel quel
166
-	return $regs[0];
165
+    // Cas normal : le script passe tel quel
166
+    return $regs[0];
167 167
 }
168 168
 
169 169
 define('_PROTEGE_BLOCS', ',<(html|code|cadre|frame|script|style)(\s[^>]*)?>(.*)</\1>,UimsS');
@@ -172,71 +172,71 @@  discard block
 block discarded – undo
172 172
 // - pour $no_transform voir le filtre post_autobr dans inc/filtres
173 173
 // https://code.spip.net/@echappe_html
174 174
 function echappe_html(
175
-	$letexte,
176
-	$source = '',
177
-	$no_transform = false,
178
-	$preg = ''
175
+    $letexte,
176
+    $source = '',
177
+    $no_transform = false,
178
+    $preg = ''
179 179
 ) {
180
-	if (!is_string($letexte) or !strlen($letexte)) {
181
-		return $letexte;
182
-	}
183
-
184
-	// si le texte recu est long PCRE risque d'exploser, on
185
-	// fait donc un mic-mac pour augmenter pcre.backtrack_limit
186
-	if (($len = strlen($letexte)) > 100000) {
187
-		if (!$old = @ini_get('pcre.backtrack_limit')) {
188
-			$old = 100000;
189
-		}
190
-		if ($len > $old) {
191
-			$a = @ini_set('pcre.backtrack_limit', $len);
192
-			spip_log("ini_set pcre.backtrack_limit=$len ($old)");
193
-		}
194
-	}
195
-
196
-	if (($preg or strpos($letexte, "<") !== false)
197
-		and preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
198
-	) {
199
-		foreach ($matches as $regs) {
200
-			// echappements tels quels ?
201
-			if ($no_transform) {
202
-				$echap = $regs[0];
203
-			} // sinon les traiter selon le cas
204
-			else {
205
-				if (function_exists($f = 'traiter_echap_' . strtolower($regs[1]))) {
206
-					$echap = $f($regs);
207
-				} else {
208
-					if (function_exists($f = $f . '_dist')) {
209
-						$echap = $f($regs);
210
-					}
211
-				}
212
-			}
213
-
214
-			$p = strpos($letexte, $regs[0]);
215
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
216
-		}
217
-	}
218
-
219
-	if ($no_transform) {
220
-		return $letexte;
221
-	}
222
-
223
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
224
-	// seulement si on a echappe les <script>
225
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
226
-	// dans une callback autonommee
227
-	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
228
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
229
-				$letexte, $matches, PREG_SET_ORDER)
230
-		) {
231
-			foreach ($matches as $regs) {
232
-				$letexte = str_replace($regs[0],
233
-					code_echappement(highlight_string($regs[0], true), $source),
234
-					$letexte);
235
-			}
236
-		}
237
-	}
238
-
239
-	return $letexte;
180
+    if (!is_string($letexte) or !strlen($letexte)) {
181
+        return $letexte;
182
+    }
183
+
184
+    // si le texte recu est long PCRE risque d'exploser, on
185
+    // fait donc un mic-mac pour augmenter pcre.backtrack_limit
186
+    if (($len = strlen($letexte)) > 100000) {
187
+        if (!$old = @ini_get('pcre.backtrack_limit')) {
188
+            $old = 100000;
189
+        }
190
+        if ($len > $old) {
191
+            $a = @ini_set('pcre.backtrack_limit', $len);
192
+            spip_log("ini_set pcre.backtrack_limit=$len ($old)");
193
+        }
194
+    }
195
+
196
+    if (($preg or strpos($letexte, "<") !== false)
197
+        and preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
198
+    ) {
199
+        foreach ($matches as $regs) {
200
+            // echappements tels quels ?
201
+            if ($no_transform) {
202
+                $echap = $regs[0];
203
+            } // sinon les traiter selon le cas
204
+            else {
205
+                if (function_exists($f = 'traiter_echap_' . strtolower($regs[1]))) {
206
+                    $echap = $f($regs);
207
+                } else {
208
+                    if (function_exists($f = $f . '_dist')) {
209
+                        $echap = $f($regs);
210
+                    }
211
+                }
212
+            }
213
+
214
+            $p = strpos($letexte, $regs[0]);
215
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
216
+        }
217
+    }
218
+
219
+    if ($no_transform) {
220
+        return $letexte;
221
+    }
222
+
223
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
224
+    // seulement si on a echappe les <script>
225
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
226
+    // dans une callback autonommee
227
+    if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
228
+        if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
229
+                $letexte, $matches, PREG_SET_ORDER)
230
+        ) {
231
+            foreach ($matches as $regs) {
232
+                $letexte = str_replace($regs[0],
233
+                    code_echappement(highlight_string($regs[0], true), $source),
234
+                    $letexte);
235
+            }
236
+        }
237
+    }
238
+
239
+    return $letexte;
240 240
 }
241 241
 
242 242
 //
@@ -245,52 +245,52 @@  discard block
 block discarded – undo
245 245
 // par propre() : exemple dans multi et dans typo()
246 246
 // https://code.spip.net/@echappe_retour
247 247
 function echappe_retour($letexte, $source = '', $filtre = "") {
248
-	if (strpos($letexte, "base64$source")) {
249
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
250
-		$max_prof = 5;
251
-		while (strpos($letexte, "<") !== false
252
-			and
253
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
254
-				$letexte, $regs, PREG_SET_ORDER)
255
-			and $max_prof--) {
256
-			foreach ($regs as $reg) {
257
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
258
-				// recherche d'attributs supplementaires
259
-				$at = array();
260
-				foreach (array('lang', 'dir') as $attr) {
261
-					if ($a = extraire_attribut($reg[0], $attr)) {
262
-						$at[$attr] = $a;
263
-					}
264
-				}
265
-				if ($at) {
266
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
267
-					foreach ($at as $attr => $a) {
268
-						$rempl = inserer_attribut($rempl, $attr, $a);
269
-					}
270
-				}
271
-				if ($filtre) {
272
-					$rempl = $filtre($rempl);
273
-				}
274
-				$letexte = str_replace($reg[0], $rempl, $letexte);
275
-			}
276
-		}
277
-	}
278
-
279
-	return $letexte;
248
+    if (strpos($letexte, "base64$source")) {
249
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
250
+        $max_prof = 5;
251
+        while (strpos($letexte, "<") !== false
252
+            and
253
+            preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
254
+                $letexte, $regs, PREG_SET_ORDER)
255
+            and $max_prof--) {
256
+            foreach ($regs as $reg) {
257
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
258
+                // recherche d'attributs supplementaires
259
+                $at = array();
260
+                foreach (array('lang', 'dir') as $attr) {
261
+                    if ($a = extraire_attribut($reg[0], $attr)) {
262
+                        $at[$attr] = $a;
263
+                    }
264
+                }
265
+                if ($at) {
266
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
267
+                    foreach ($at as $attr => $a) {
268
+                        $rempl = inserer_attribut($rempl, $attr, $a);
269
+                    }
270
+                }
271
+                if ($filtre) {
272
+                    $rempl = $filtre($rempl);
273
+                }
274
+                $letexte = str_replace($reg[0], $rempl, $letexte);
275
+            }
276
+        }
277
+    }
278
+
279
+    return $letexte;
280 280
 }
281 281
 
282 282
 // Reinserer le javascript de confiance (venant des modeles)
283 283
 
284 284
 // https://code.spip.net/@echappe_retour_modeles
285 285
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
286
-	$letexte = echappe_retour($letexte);
286
+    $letexte = echappe_retour($letexte);
287 287
 
288
-	// Dans les appels directs hors squelette, securiser aussi ici
289
-	if ($interdire_scripts) {
290
-		$letexte = interdire_scripts($letexte);
291
-	}
288
+    // Dans les appels directs hors squelette, securiser aussi ici
289
+    if ($interdire_scripts) {
290
+        $letexte = interdire_scripts($letexte);
291
+    }
292 292
 
293
-	return trim($letexte);
293
+    return trim($letexte);
294 294
 }
295 295
 
296 296
 
@@ -318,130 +318,130 @@  discard block
 block discarded – undo
318 318
  *     Texte coupé
319 319
  **/
320 320
 function couper($texte, $taille = 50, $suite = null) {
321
-	if (!($length = strlen($texte)) or $taille <= 0) {
322
-		return '';
323
-	}
324
-	$offset = 400 + 2 * $taille;
325
-	while ($offset < $length
326
-		and strlen(preg_replace(",<(!--|\w|/)[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
327
-		$offset = 2 * $offset;
328
-	}
329
-	if ($offset < $length
330
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
331
-	) {
332
-		$p_tag_fermant = strpos($texte, '>', $offset);
333
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
334
-			$offset = $p_tag_fermant + 1;
335
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
336
-	}
337
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
338
-
339
-	if (!function_exists('nettoyer_raccourcis_typo')) {
340
-		include_spip('inc/lien');
341
-	}
342
-	$texte = nettoyer_raccourcis_typo($texte);
343
-
344
-	// balises de sauts de ligne et paragraphe
345
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
346
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
347
-
348
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
349
-	$texte = str_replace("\n\n", "\r", $texte);
350
-
351
-	// supprimer les tags
352
-	$texte = supprimer_tags($texte);
353
-	$texte = trim(str_replace("\n", " ", $texte));
354
-	$texte .= "\n";  // marquer la fin
355
-
356
-	// corriger la longueur de coupe
357
-	// en fonction de la presence de caracteres utf
358
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
359
-		$long = charset2unicode($texte);
360
-		$long = spip_substr($long, 0, max($taille, 1));
361
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
362
-		$taille += $nbcharutf;
363
-	}
364
-
365
-
366
-	// couper au mot precedent
367
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
368
-	$u = $GLOBALS['meta']['pcre_u'];
369
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
370
-	if (is_null($suite)) {
371
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
372
-	}
373
-	$points = $suite;
374
-
375
-	// trop court ? ne pas faire de (...)
376
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
377
-		$points = '';
378
-		$long = spip_substr($texte, 0, $taille);
379
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
380
-		// encore trop court ? couper au caractere
381
-		if (spip_strlen($texte) < 0.75 * $taille) {
382
-			$texte = $long;
383
-		}
384
-	} else {
385
-		$texte = $court;
386
-	}
387
-
388
-	if (strpos($texte, "\n"))  // la fin est encore la : c'est qu'on n'a pas de texte de suite
389
-	{
390
-		$points = '';
391
-	}
392
-
393
-	// remettre les paragraphes
394
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
395
-
396
-	// supprimer l'eventuelle entite finale mal coupee
397
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
398
-
399
-	return quote_amp(trim($texte)) . $points;
321
+    if (!($length = strlen($texte)) or $taille <= 0) {
322
+        return '';
323
+    }
324
+    $offset = 400 + 2 * $taille;
325
+    while ($offset < $length
326
+        and strlen(preg_replace(",<(!--|\w|/)[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
327
+        $offset = 2 * $offset;
328
+    }
329
+    if ($offset < $length
330
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
331
+    ) {
332
+        $p_tag_fermant = strpos($texte, '>', $offset);
333
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
334
+            $offset = $p_tag_fermant + 1;
335
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
336
+    }
337
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
338
+
339
+    if (!function_exists('nettoyer_raccourcis_typo')) {
340
+        include_spip('inc/lien');
341
+    }
342
+    $texte = nettoyer_raccourcis_typo($texte);
343
+
344
+    // balises de sauts de ligne et paragraphe
345
+    $texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
346
+    $texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
347
+
348
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
349
+    $texte = str_replace("\n\n", "\r", $texte);
350
+
351
+    // supprimer les tags
352
+    $texte = supprimer_tags($texte);
353
+    $texte = trim(str_replace("\n", " ", $texte));
354
+    $texte .= "\n";  // marquer la fin
355
+
356
+    // corriger la longueur de coupe
357
+    // en fonction de la presence de caracteres utf
358
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
359
+        $long = charset2unicode($texte);
360
+        $long = spip_substr($long, 0, max($taille, 1));
361
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
362
+        $taille += $nbcharutf;
363
+    }
364
+
365
+
366
+    // couper au mot precedent
367
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
368
+    $u = $GLOBALS['meta']['pcre_u'];
369
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
370
+    if (is_null($suite)) {
371
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
372
+    }
373
+    $points = $suite;
374
+
375
+    // trop court ? ne pas faire de (...)
376
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
377
+        $points = '';
378
+        $long = spip_substr($texte, 0, $taille);
379
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
380
+        // encore trop court ? couper au caractere
381
+        if (spip_strlen($texte) < 0.75 * $taille) {
382
+            $texte = $long;
383
+        }
384
+    } else {
385
+        $texte = $court;
386
+    }
387
+
388
+    if (strpos($texte, "\n"))  // la fin est encore la : c'est qu'on n'a pas de texte de suite
389
+    {
390
+        $points = '';
391
+    }
392
+
393
+    // remettre les paragraphes
394
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
395
+
396
+    // supprimer l'eventuelle entite finale mal coupee
397
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
398
+
399
+    return quote_amp(trim($texte)) . $points;
400 400
 }
401 401
 
402 402
 
403 403
 // https://code.spip.net/@protege_js_modeles
404 404
 function protege_js_modeles($t) {
405
-	if (isset($GLOBALS['visiteur_session'])) {
406
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
407
-			if (!defined('_PROTEGE_JS_MODELES')) {
408
-				include_spip('inc/acces');
409
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
410
-			}
411
-			foreach ($r as $regs) {
412
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
413
-			}
414
-		}
415
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
416
-			if (!defined('_PROTEGE_PHP_MODELES')) {
417
-				include_spip('inc/acces');
418
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
419
-			}
420
-			foreach ($r as $regs) {
421
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
422
-			}
423
-		}
424
-	}
425
-
426
-	return $t;
405
+    if (isset($GLOBALS['visiteur_session'])) {
406
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
407
+            if (!defined('_PROTEGE_JS_MODELES')) {
408
+                include_spip('inc/acces');
409
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
410
+            }
411
+            foreach ($r as $regs) {
412
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
413
+            }
414
+        }
415
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
416
+            if (!defined('_PROTEGE_PHP_MODELES')) {
417
+                include_spip('inc/acces');
418
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
419
+            }
420
+            foreach ($r as $regs) {
421
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
422
+            }
423
+        }
424
+    }
425
+
426
+    return $t;
427 427
 }
428 428
 
429 429
 
430 430
 function echapper_faux_tags($letexte) {
431
-	if (strpos($letexte, '<') === false) {
432
-		return $letexte;
433
-	}
434
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
435
-
436
-	$letexte = "";
437
-	while (count($textMatches)) {
438
-		// un texte a echapper
439
-		$letexte .= str_replace("<", '&lt;', array_shift($textMatches));
440
-		// un tag html qui a servit a faite le split
441
-		$letexte .= array_shift($textMatches);
442
-	}
443
-
444
-	return $letexte;
431
+    if (strpos($letexte, '<') === false) {
432
+        return $letexte;
433
+    }
434
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
435
+
436
+    $letexte = "";
437
+    while (count($textMatches)) {
438
+        // un texte a echapper
439
+        $letexte .= str_replace("<", '&lt;', array_shift($textMatches));
440
+        // un tag html qui a servit a faite le split
441
+        $letexte .= array_shift($textMatches);
442
+    }
443
+
444
+    return $letexte;
445 445
 }
446 446
 
447 447
 /**
@@ -454,44 +454,44 @@  discard block
 block discarded – undo
454 454
  * @return string
455 455
  */
456 456
 function echapper_html_suspect($texte, $strict=true) {
457
-	static $echapper_html_suspect;
458
-	if (!$texte or !is_string($texte)) {
459
-		return $texte;
460
-	}
461
-
462
-	if (!isset($echapper_html_suspect)) {
463
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
464
-	}
465
-	// si fonction personalisee, on delegue
466
-	if ($echapper_html_suspect) {
467
-		return $echapper_html_suspect($texte, $strict);
468
-	}
469
-
470
-	if (strpos($texte, '<') === false
471
-	  or strpos($texte, '=') === false) {
472
-		return $texte;
473
-	}
474
-
475
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
476
-	// car sinon on declenche sur les modeles ou ressources
477
-	if (!$strict and
478
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
479
-	  ){
480
-		return $texte;
481
-	}
482
-
483
-	// on teste sur strlen car safehtml supprime le contenu dangereux
484
-	// mais il peut aussi changer des ' en " sur les attributs html,
485
-	// donc un test d'egalite est trop strict
486
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
487
-		$texte = str_replace("<", "&lt;", $texte);
488
-		if (!function_exists('attribut_html')) {
489
-			include_spip('inc/filtres');
490
-		}
491
-		$texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
492
-	}
493
-
494
-	return $texte;
457
+    static $echapper_html_suspect;
458
+    if (!$texte or !is_string($texte)) {
459
+        return $texte;
460
+    }
461
+
462
+    if (!isset($echapper_html_suspect)) {
463
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
464
+    }
465
+    // si fonction personalisee, on delegue
466
+    if ($echapper_html_suspect) {
467
+        return $echapper_html_suspect($texte, $strict);
468
+    }
469
+
470
+    if (strpos($texte, '<') === false
471
+      or strpos($texte, '=') === false) {
472
+        return $texte;
473
+    }
474
+
475
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
476
+    // car sinon on declenche sur les modeles ou ressources
477
+    if (!$strict and
478
+      (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
479
+        ){
480
+        return $texte;
481
+    }
482
+
483
+    // on teste sur strlen car safehtml supprime le contenu dangereux
484
+    // mais il peut aussi changer des ' en " sur les attributs html,
485
+    // donc un test d'egalite est trop strict
486
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
487
+        $texte = str_replace("<", "&lt;", $texte);
488
+        if (!function_exists('attribut_html')) {
489
+            include_spip('inc/filtres');
490
+        }
491
+        $texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
492
+    }
493
+
494
+    return $texte;
495 495
 }
496 496
 
497 497
 
@@ -512,27 +512,27 @@  discard block
 block discarded – undo
512 512
  *      Texte sécurisé
513 513
  **/
514 514
 function safehtml($t) {
515
-	static $safehtml;
516
-
517
-	if (!$t or !is_string($t)) {
518
-		return $t;
519
-	}
520
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
521
-	if (strpos($t, '<') === false) {
522
-		return str_replace("\x00", '', $t);
523
-	}
524
-
525
-	$t = interdire_scripts($t); // jolifier le php
526
-	$t = echappe_js($t);
527
-
528
-	if (!isset($safehtml)) {
529
-		$safehtml = charger_fonction('safehtml', 'inc', true);
530
-	}
531
-	if ($safehtml) {
532
-		$t = $safehtml($t);
533
-	}
534
-
535
-	return interdire_scripts($t); // interdire le php (2 precautions)
515
+    static $safehtml;
516
+
517
+    if (!$t or !is_string($t)) {
518
+        return $t;
519
+    }
520
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
521
+    if (strpos($t, '<') === false) {
522
+        return str_replace("\x00", '', $t);
523
+    }
524
+
525
+    $t = interdire_scripts($t); // jolifier le php
526
+    $t = echappe_js($t);
527
+
528
+    if (!isset($safehtml)) {
529
+        $safehtml = charger_fonction('safehtml', 'inc', true);
530
+    }
531
+    if ($safehtml) {
532
+        $t = $safehtml($t);
533
+    }
534
+
535
+    return interdire_scripts($t); // interdire le php (2 precautions)
536 536
 }
537 537
 
538 538
 
@@ -554,10 +554,10 @@  discard block
 block discarded – undo
554 554
  *     Texte sans les modèles d'image
555 555
  **/
556 556
 function supprime_img($letexte, $message = null) {
557
-	if ($message === null) {
558
-		$message = '(' . _T('img_indisponible') . ')';
559
-	}
557
+    if ($message === null) {
558
+        $message = '(' . _T('img_indisponible') . ')';
559
+    }
560 560
 
561
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
562
-		$message, $letexte);
561
+    return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
562
+        $message, $letexte);
563 563
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	// celle du texte) et public (spip_lang est la langue du texte)
45 45
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
48 48
 	if ($dir == 'rtl') {
49 49
 		$p .= '_rtl';
50 50
 	}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 }
68 68
 
69 69
 if (!defined('_BALISES_BLOCS_REGEXP')) {
70
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
70
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
71 71
 }
72 72
 
73 73
 //
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	// Tester si on echappe en span ou en div
87 87
 	if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
88
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89 89
 	}
90 90
 
91 91
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 // Echapper les <code>...</ code>
113 113
 // https://code.spip.net/@traiter_echap_code_dist
114 114
 function traiter_echap_code_dist($regs) {
115
-	list(, , $att, $corps) = $regs;
115
+	list(,, $att, $corps) = $regs;
116 116
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
117 117
 
118 118
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 		$echap = nl2br($echap);
124 124
 		$echap = "<div style='text-align: left;' "
125 125
 			. "class='spip_code' dir='ltr'><code$att>"
126
-			. $echap . "</code></div>";
126
+			. $echap."</code></div>";
127 127
 	} else {
128
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
128
+		$echap = "<code$att class='spip_code' dir='ltr'>".$echap."</code>";
129 129
 	}
130 130
 
131 131
 	$echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 				$echap = $regs[0];
203 203
 			} // sinon les traiter selon le cas
204 204
 			else {
205
-				if (function_exists($f = 'traiter_echap_' . strtolower($regs[1]))) {
205
+				if (function_exists($f = 'traiter_echap_'.strtolower($regs[1]))) {
206 206
 					$echap = $f($regs);
207 207
 				} else {
208
-					if (function_exists($f = $f . '_dist')) {
208
+					if (function_exists($f = $f.'_dist')) {
209 209
 						$echap = $f($regs);
210 210
 					}
211 211
 				}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	// (derogatoire car on ne peut pas faire passer < ? ... ? >
226 226
 	// dans une callback autonommee
227 227
 	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
228
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
228
+		if (strpos($letexte, "<"."?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
229 229
 				$letexte, $matches, PREG_SET_ORDER)
230 230
 		) {
231 231
 			foreach ($matches as $regs) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$max_prof = 5;
251 251
 		while (strpos($letexte, "<") !== false
252 252
 			and
253
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
253
+			preg_match_all(',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
254 254
 				$letexte, $regs, PREG_SET_ORDER)
255 255
 			and $max_prof--) {
256 256
 			foreach ($regs as $reg) {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					}
264 264
 				}
265 265
 				if ($at) {
266
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
266
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
267 267
 					foreach ($at as $attr => $a) {
268 268
 						$rempl = inserer_attribut($rempl, $attr, $a);
269 269
 					}
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	$texte = nettoyer_raccourcis_typo($texte);
343 343
 
344 344
 	// balises de sauts de ligne et paragraphe
345
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
346
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
345
+	$texte = preg_replace("/<p( [^>]*)?".">/", "\r", $texte);
346
+	$texte = preg_replace("/<br( [^>]*)?".">/", "\n", $texte);
347 347
 
348 348
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
349 349
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	// supprimer les tags
352 352
 	$texte = supprimer_tags($texte);
353 353
 	$texte = trim(str_replace("\n", " ", $texte));
354
-	$texte .= "\n";  // marquer la fin
354
+	$texte .= "\n"; // marquer la fin
355 355
 
356 356
 	// corriger la longueur de coupe
357 357
 	// en fonction de la presence de caracteres utf
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	// couper au mot precedent
367 367
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
368 368
 	$u = $GLOBALS['meta']['pcre_u'];
369
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
369
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
370 370
 	if (is_null($suite)) {
371 371
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
372 372
 	}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
377 377
 		$points = '';
378 378
 		$long = spip_substr($texte, 0, $taille);
379
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
379
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
380 380
 		// encore trop court ? couper au caractere
381 381
 		if (spip_strlen($texte) < 0.75 * $taille) {
382 382
 			$texte = $long;
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	// supprimer l'eventuelle entite finale mal coupee
397 397
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
398 398
 
399
-	return quote_amp(trim($texte)) . $points;
399
+	return quote_amp(trim($texte)).$points;
400 400
 }
401 401
 
402 402
 
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
410 410
 			}
411 411
 			foreach ($r as $regs) {
412
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
412
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
413 413
 			}
414 414
 		}
415
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
415
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
416 416
 			if (!defined('_PROTEGE_PHP_MODELES')) {
417 417
 				include_spip('inc/acces');
418 418
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
419 419
 			}
420 420
 			foreach ($r as $regs) {
421
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
421
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
422 422
 			}
423 423
 		}
424 424
 	}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
  * @param bool $strict
454 454
  * @return string
455 455
  */
456
-function echapper_html_suspect($texte, $strict=true) {
456
+function echapper_html_suspect($texte, $strict = true) {
457 457
 	static $echapper_html_suspect;
458 458
 	if (!$texte or !is_string($texte)) {
459 459
 		return $texte;
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
476 476
 	// car sinon on declenche sur les modeles ou ressources
477 477
 	if (!$strict and
478
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
479
-	  ){
478
+	  (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
479
+	  ) {
480 480
 		return $texte;
481 481
 	}
482 482
 
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
  **/
556 556
 function supprime_img($letexte, $message = null) {
557 557
 	if ($message === null) {
558
-		$message = '(' . _T('img_indisponible') . ')';
558
+		$message = '('._T('img_indisponible').')';
559 559
 	}
560 560
 
561
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
561
+	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
562 562
 		$message, $letexte);
563 563
 }
Please login to merge, or discard this patch.
ecrire/inc/utils.php 3 patches
Doc Comments   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -985,6 +985,9 @@  discard block
 block discarded – undo
985 985
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
986 986
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
987 987
 // https://code.spip.net/@spip_touch
988
+/**
989
+ * @param string $fichier
990
+ */
988 991
 function spip_touch($fichier, $duree = 0, $touch = true) {
989 992
 	if ($duree) {
990 993
 		clearstatcache();
@@ -1062,7 +1065,7 @@  discard block
 block discarded – undo
1062 1065
  * @param string $description
1063 1066
  *     Une description humainement compréhensible de ce que fait la tâche
1064 1067
  *     (essentiellement pour l’affichage dans la page de suivi de l’espace privé)
1065
- * @param array $arguments
1068
+ * @param integer[] $arguments
1066 1069
  *     Facultatif, vide par défaut : les arguments qui seront passés à la fonction, sous forme de tableau PHP
1067 1070
  * @param string $file
1068 1071
  *     Facultatif, vide par défaut : nom du fichier à inclure, via `include_spip($file)`
@@ -1101,7 +1104,7 @@  discard block
 block discarded – undo
1101 1104
  *
1102 1105
  * @param int $id_job
1103 1106
  *  id of jonb to delete
1104
- * @return bool
1107
+ * @return boolean|string
1105 1108
  */
1106 1109
 function job_queue_remove($id_job) {
1107 1110
 	include_spip('inc/queue');
@@ -1417,6 +1420,9 @@  discard block
 block discarded – undo
1417 1420
 	return $themes;
1418 1421
 }
1419 1422
 
1423
+/**
1424
+ * @return string
1425
+ */
1420 1426
 function find_in_theme($file, $subdir = '', $include = false) {
1421 1427
 	static $themefiles = array();
1422 1428
 	if (isset($themefiles["$subdir$file"])) {
@@ -1861,6 +1867,9 @@  discard block
 block discarded – undo
1861 1867
 }
1862 1868
 
1863 1869
 // https://code.spip.net/@generer_url_entite_absolue
1870
+/**
1871
+ * @param boolean|string $connect
1872
+ */
1864 1873
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1865 1874
 	if (!$connect) {
1866 1875
 		$connect = true;
@@ -2118,7 +2127,7 @@  discard block
 block discarded – undo
2118 2127
  *
2119 2128
  * @param string $script
2120 2129
  *     Nom de la page
2121
- * @param string|array $args
2130
+ * @param string $args
2122 2131
  *     Arguments à transmettre a l'URL,
2123 2132
  *      soit sous la forme d'un string tel que `arg1=yy&arg2=zz`
2124 2133
  *      soit sous la forme d'un array tel que array( `arg1` => `yy`, `arg2` => `zz` )
@@ -3315,7 +3324,7 @@  discard block
 block discarded – undo
3315 3324
 /**
3316 3325
  * Trouve un squelette dans le repertoire modeles/
3317 3326
  *
3318
- * @param  $nom
3327
+ * @param  string $nom
3319 3328
  * @return string
3320 3329
  */
3321 3330
 function trouve_modele($nom) {
@@ -3533,7 +3542,7 @@  discard block
 block discarded – undo
3533 3542
 		 *
3534 3543
 		 * @param array $input A multi-dimensional array (record set) from which to pull
3535 3544
 		 *                     a column of values.
3536
-		 * @param mixed $columnKey The column of values to return. This value may be the
3545
+		 * @param string $columnKey The column of values to return. This value may be the
3537 3546
 		 *                         integer key of the column you wish to retrieve, or it
3538 3547
 		 *                         may be the string key name for an associative array.
3539 3548
 		 * @param mixed $indexKey (Optional.) The column to use as the index/keys for
Please login to merge, or discard this patch.
Indentation   +2209 added lines, -2210 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,63 +48,63 @@  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 = array();
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 (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
-		// si le fichier truc/machin/nom.php n'existe pas,
83
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
-	) {
86
-		include_spip(substr($dossier, 0, -1));
87
-	}
88
-	if (function_exists($f)) {
89
-		return $f;
90
-	}
91
-	if (function_exists($g)) {
92
-		return $g;
93
-	}
94
-
95
-	if ($continue) {
96
-		return $echecs[$f] = false;
97
-	}
98
-
99
-	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
-		($inc ? "" : " (fichier $d absent de $dossier)"));
102
-
103
-	include_spip('inc/minipres');
104
-	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
107
-	exit;
51
+    static $echecs = array();
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 (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+        // si le fichier truc/machin/nom.php n'existe pas,
83
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
+    ) {
86
+        include_spip(substr($dossier, 0, -1));
87
+    }
88
+    if (function_exists($f)) {
89
+        return $f;
90
+    }
91
+    if (function_exists($g)) {
92
+        return $g;
93
+    }
94
+
95
+    if ($continue) {
96
+        return $echecs[$f] = false;
97
+    }
98
+
99
+    // Echec : message d'erreur
100
+    spip_log("fonction $nom ($f ou $g) indisponible" .
101
+        ($inc ? "" : " (fichier $d absent de $dossier)"));
102
+
103
+    include_spip('inc/minipres');
104
+    echo minipres(_T('forum_titre_erreur'),
105
+        _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
+        array('all_inline'=>true,'status'=>404));
107
+    exit;
108 108
 }
109 109
 
110 110
 /**
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function include_once_check($file) {
117
-	if (file_exists($file)) {
118
-		include_once $file;
117
+    if (file_exists($file)) {
118
+        include_once $file;
119 119
 
120
-		return true;
121
-	}
122
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
-	$crash = ($crash ? $crash : array());
124
-	$crash[$file] = true;
125
-	ecrire_meta('message_crash_plugins', serialize($crash));
120
+        return true;
121
+    }
122
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
+    $crash = ($crash ? $crash : array());
124
+    $crash[$file] = true;
125
+    ecrire_meta('message_crash_plugins', serialize($crash));
126 126
 
127
-	return false;
127
+    return false;
128 128
 }
129 129
 
130 130
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+    return find_in_path($f . '.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+    return find_in_path($f . '.php', '', 'required');
172 172
 }
173 173
 
174 174
 /**
@@ -194,22 +194,22 @@  discard block
 block discarded – undo
194 194
  *     Les paramètres du pipeline modifiés
195 195
  **/
196 196
 function minipipe($fonc, &$val) {
197
-	// fonction
198
-	if (function_exists($fonc)) {
199
-		$val = call_user_func($fonc, $val);
200
-	} // Class::Methode
201
-	else {
202
-		if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
203
-			and $methode = array($regs[1], $regs[2])
204
-			and is_callable($methode)
205
-		) {
206
-			$val = call_user_func($methode, $val);
207
-		} else {
208
-			spip_log("Erreur - '$fonc' non definie !");
209
-		}
210
-	}
197
+    // fonction
198
+    if (function_exists($fonc)) {
199
+        $val = call_user_func($fonc, $val);
200
+    } // Class::Methode
201
+    else {
202
+        if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
203
+            and $methode = array($regs[1], $regs[2])
204
+            and is_callable($methode)
205
+        ) {
206
+            $val = call_user_func($methode, $val);
207
+        } else {
208
+            spip_log("Erreur - '$fonc' non definie !");
209
+        }
210
+    }
211 211
 
212
-	return $val;
212
+    return $val;
213 213
 }
214 214
 
215 215
 /**
@@ -240,45 +240,45 @@  discard block
 block discarded – undo
240 240
  *     Résultat
241 241
  */
242 242
 function pipeline($action, $val = null) {
243
-	static $charger;
244
-
245
-	// chargement initial des fonctions mises en cache, ou generation du cache
246
-	if (!$charger) {
247
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
248
-			include_spip('inc/plugin');
249
-			// generer les fichiers php precompiles
250
-			// de chargement des plugins et des pipelines
251
-			actualise_plugins_actifs();
252
-			if (!($ok = @is_readable($charger))) {
253
-				spip_log("fichier $charger pas cree");
254
-			}
255
-		}
256
-
257
-		if ($ok) {
258
-			include_once $charger;
259
-		}
260
-	}
261
-
262
-	// appliquer notre fonction si elle existe
263
-	$fonc = 'execute_pipeline_' . strtolower($action);
264
-	if (function_exists($fonc)) {
265
-		$val = $fonc($val);
266
-	} // plantage ?
267
-	else {
268
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
269
-	}
270
-
271
-	// si le flux est une table avec 2 cle args&data
272
-	// on ne ressort du pipe que les donnees dans 'data'
273
-	// array_key_exists pour php 4.1.0
274
-	if (is_array($val)
275
-		and count($val) == 2
276
-		and (array_key_exists('data', $val))
277
-	) {
278
-		$val = $val['data'];
279
-	}
280
-
281
-	return $val;
243
+    static $charger;
244
+
245
+    // chargement initial des fonctions mises en cache, ou generation du cache
246
+    if (!$charger) {
247
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
248
+            include_spip('inc/plugin');
249
+            // generer les fichiers php precompiles
250
+            // de chargement des plugins et des pipelines
251
+            actualise_plugins_actifs();
252
+            if (!($ok = @is_readable($charger))) {
253
+                spip_log("fichier $charger pas cree");
254
+            }
255
+        }
256
+
257
+        if ($ok) {
258
+            include_once $charger;
259
+        }
260
+    }
261
+
262
+    // appliquer notre fonction si elle existe
263
+    $fonc = 'execute_pipeline_' . strtolower($action);
264
+    if (function_exists($fonc)) {
265
+        $val = $fonc($val);
266
+    } // plantage ?
267
+    else {
268
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
269
+    }
270
+
271
+    // si le flux est une table avec 2 cle args&data
272
+    // on ne ressort du pipe que les donnees dans 'data'
273
+    // array_key_exists pour php 4.1.0
274
+    if (is_array($val)
275
+        and count($val) == 2
276
+        and (array_key_exists('data', $val))
277
+    ) {
278
+        $val = $val['data'];
279
+    }
280
+
281
+    return $val;
282 282
 }
283 283
 
284 284
 /**
@@ -322,35 +322,35 @@  discard block
 block discarded – undo
322 322
  *     paramètre est planté pour cause de compatibilité ascendante.
323 323
  */
324 324
 function spip_log($message = null, $name = null) {
325
-	static $pre = array();
326
-	static $log;
327
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
328
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
329
-		$logname = null;
330
-	}
331
-	if (!isset($regs[2]) or !$niveau = $regs[2]) {
332
-		$niveau = _LOG_INFO;
333
-	}
334
-
335
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
336
-		if (!$pre) {
337
-			$pre = array(
338
-				_LOG_HS => 'HS:',
339
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
340
-				_LOG_CRITIQUE => 'CRITIQUE:',
341
-				_LOG_ERREUR => 'ERREUR:',
342
-				_LOG_AVERTISSEMENT => 'WARNING:',
343
-				_LOG_INFO_IMPORTANTE => '!INFO:',
344
-				_LOG_INFO => 'info:',
345
-				_LOG_DEBUG => 'debug:'
346
-			);
347
-			$log = charger_fonction('log', 'inc');
348
-		}
349
-		if (!is_string($message)) {
350
-			$message = print_r($message, true);
351
-		}
352
-		$log($pre[$niveau] . ' ' . $message, $logname);
353
-	}
325
+    static $pre = array();
326
+    static $log;
327
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
328
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
329
+        $logname = null;
330
+    }
331
+    if (!isset($regs[2]) or !$niveau = $regs[2]) {
332
+        $niveau = _LOG_INFO;
333
+    }
334
+
335
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
336
+        if (!$pre) {
337
+            $pre = array(
338
+                _LOG_HS => 'HS:',
339
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
340
+                _LOG_CRITIQUE => 'CRITIQUE:',
341
+                _LOG_ERREUR => 'ERREUR:',
342
+                _LOG_AVERTISSEMENT => 'WARNING:',
343
+                _LOG_INFO_IMPORTANTE => '!INFO:',
344
+                _LOG_INFO => 'info:',
345
+                _LOG_DEBUG => 'debug:'
346
+            );
347
+            $log = charger_fonction('log', 'inc');
348
+        }
349
+        if (!is_string($message)) {
350
+            $message = print_r($message, true);
351
+        }
352
+        $log($pre[$niveau] . ' ' . $message, $logname);
353
+    }
354 354
 }
355 355
 
356 356
 /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
  * @param array $opt Tableau d'options
362 362
  **/
363 363
 function journal($phrase, $opt = array()) {
364
-	$journal = charger_fonction('journal', 'inc');
365
-	$journal($phrase, $opt);
364
+    $journal = charger_fonction('journal', 'inc');
365
+    $journal($phrase, $opt);
366 366
 }
367 367
 
368 368
 
@@ -381,36 +381,36 @@  discard block
 block discarded – undo
381 381
  **/
382 382
 function _request($var, $c = false) {
383 383
 
384
-	if (is_array($c)) {
385
-		return isset($c[$var]) ? $c[$var] : null;
386
-	}
384
+    if (is_array($c)) {
385
+        return isset($c[$var]) ? $c[$var] : null;
386
+    }
387 387
 
388
-	if (isset($_GET[$var])) {
389
-		$a = $_GET[$var];
390
-	} elseif (isset($_POST[$var])) {
391
-		$a = $_POST[$var];
392
-	} else {
393
-		return null;
394
-	}
388
+    if (isset($_GET[$var])) {
389
+        $a = $_GET[$var];
390
+    } elseif (isset($_POST[$var])) {
391
+        $a = $_POST[$var];
392
+    } else {
393
+        return null;
394
+    }
395 395
 
396
-	// Si on est en ajax et en POST tout a ete encode
397
-	// via encodeURIComponent, il faut donc repasser
398
-	// dans le charset local...
399
-	if (defined('_AJAX')
400
-		and _AJAX
401
-		and isset($GLOBALS['meta']['charset'])
402
-		and $GLOBALS['meta']['charset'] != 'utf-8'
403
-		and is_string($a)
404
-		// check rapide mais pas fiable
405
-		and preg_match(',[\x80-\xFF],', $a)
406
-		// check fiable
407
-		and include_spip('inc/charsets')
408
-		and is_utf8($a)
409
-	) {
410
-		return importer_charset($a, 'utf-8');
411
-	}
396
+    // Si on est en ajax et en POST tout a ete encode
397
+    // via encodeURIComponent, il faut donc repasser
398
+    // dans le charset local...
399
+    if (defined('_AJAX')
400
+        and _AJAX
401
+        and isset($GLOBALS['meta']['charset'])
402
+        and $GLOBALS['meta']['charset'] != 'utf-8'
403
+        and is_string($a)
404
+        // check rapide mais pas fiable
405
+        and preg_match(',[\x80-\xFF],', $a)
406
+        // check fiable
407
+        and include_spip('inc/charsets')
408
+        and is_utf8($a)
409
+    ) {
410
+        return importer_charset($a, 'utf-8');
411
+    }
412 412
 
413
-	return $a;
413
+    return $a;
414 414
 }
415 415
 
416 416
 
@@ -428,22 +428,22 @@  discard block
 block discarded – undo
428 428
  *     - false sinon
429 429
  **/
430 430
 function set_request($var, $val = null, $c = false) {
431
-	if (is_array($c)) {
432
-		unset($c[$var]);
433
-		if ($val !== null) {
434
-			$c[$var] = $val;
435
-		}
431
+    if (is_array($c)) {
432
+        unset($c[$var]);
433
+        if ($val !== null) {
434
+            $c[$var] = $val;
435
+        }
436 436
 
437
-		return $c;
438
-	}
437
+        return $c;
438
+    }
439 439
 
440
-	unset($_GET[$var]);
441
-	unset($_POST[$var]);
442
-	if ($val !== null) {
443
-		$_GET[$var] = $val;
444
-	}
440
+    unset($_GET[$var]);
441
+    unset($_POST[$var]);
442
+    if ($val !== null) {
443
+        $_GET[$var] = $val;
444
+    }
445 445
 
446
-	return false; # n'affecte pas $c
446
+    return false; # n'affecte pas $c
447 447
 }
448 448
 
449 449
 /**
@@ -463,25 +463,25 @@  discard block
 block discarded – undo
463 463
  * @return array|mixed|string
464 464
  */
465 465
 function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') {
466
-	if (is_array($value)) {
467
-		if ($key=='*') {
468
-			$key = array_keys($value);
469
-		}
470
-		if (!is_array($key)) {
471
-			$key = [$key];
472
-		}
473
-		foreach ($key as $k) {
474
-			if (!empty($value[$k])) {
475
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
476
-			}
477
-		}
478
-		return $value;
479
-	}
480
-	// si la valeur vient des GET ou POST on la sanitize
481
-	if (!empty($value) and $value == _request($key)) {
482
-		$value = $sanitize_function($value);
483
-	}
484
-	return $value;
466
+    if (is_array($value)) {
467
+        if ($key=='*') {
468
+            $key = array_keys($value);
469
+        }
470
+        if (!is_array($key)) {
471
+            $key = [$key];
472
+        }
473
+        foreach ($key as $k) {
474
+            if (!empty($value[$k])) {
475
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
476
+            }
477
+        }
478
+        return $value;
479
+    }
480
+    // si la valeur vient des GET ou POST on la sanitize
481
+    if (!empty($value) and $value == _request($key)) {
482
+        $value = $sanitize_function($value);
483
+    }
484
+    return $value;
485 485
 }
486 486
 
487 487
 /**
@@ -489,23 +489,22 @@  discard block
 block discarded – undo
489 489
  * 
490 490
  * On est sur le web, on exclut certains protocoles, 
491 491
  * notamment 'file://', 'php://' et d'autres…
492
-
493 492
  * @param string $url
494 493
  * @return bool
495 494
  */
496 495
 function tester_url_absolue($url) {
497
-	$url = trim($url);
498
-	if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
499
-		if (
500
-			isset($m[1])
501
-			and $p = strtolower(rtrim($m[1], ':'))
502
-			and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
503
-		  ) {
504
-			return false;
505
-		}
506
-		return true;
507
-	}
508
-	return false;
496
+    $url = trim($url);
497
+    if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
498
+        if (
499
+            isset($m[1])
500
+            and $p = strtolower(rtrim($m[1], ':'))
501
+            and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
502
+            ) {
503
+            return false;
504
+        }
505
+        return true;
506
+    }
507
+    return false;
509 508
 }
510 509
 
511 510
 /**
@@ -527,94 +526,94 @@  discard block
 block discarded – undo
527 526
  * @return string URL
528 527
  */
529 528
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
530
-	// requete erronnee : plusieurs variable dans $c et aucun $v
531
-	if (strpos($c, "|") !== false and is_null($v)) {
532
-		return null;
533
-	}
534
-
535
-	// lever l'#ancre
536
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
537
-		$url = $r[1];
538
-		$ancre = $r[2];
539
-	} else {
540
-		$ancre = '';
541
-	}
542
-
543
-	// eclater
544
-	$url = preg_split(',[?]|&amp;|&,', $url);
545
-
546
-	// recuperer la base
547
-	$a = array_shift($url);
548
-	if (!$a) {
549
-		$a = './';
550
-	}
551
-
552
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
553
-	$ajouts = array_flip(explode('|', $c));
554
-	$u = is_array($v) ? $v : rawurlencode($v);
555
-	$testv = (is_array($v) ? count($v) : strlen($v));
556
-	$v_read = null;
557
-	// lire les variables et agir
558
-	foreach ($url as $n => $val) {
559
-		if (preg_match($regexp, urldecode($val), $r)) {
560
-			$r = array_pad($r, 3, null);
561
-			if ($v === null) {
562
-				// c'est un tableau, on memorise les valeurs
563
-				if (substr($r[1], -2) == "[]") {
564
-					if (!$v_read) {
565
-						$v_read = array();
566
-					}
567
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
568
-				} // c'est un scalaire, on retourne direct
569
-				else {
570
-					return $r[2] ? substr($r[2], 1) : '';
571
-				}
572
-			} // suppression
573
-			elseif (!$testv) {
574
-				unset($url[$n]);
575
-			}
576
-			// Ajout. Pour une variable, remplacer au meme endroit,
577
-			// pour un tableau ce sera fait dans la prochaine boucle
578
-			elseif (substr($r[1], -2) != '[]') {
579
-				$url[$n] = $r[1] . '=' . $u;
580
-				unset($ajouts[$r[1]]);
581
-			}
582
-			// Pour les tableaux on laisse tomber les valeurs de
583
-			// départ, on remplira à l'étape suivante
584
-			else {
585
-				unset($url[$n]);
586
-			}
587
-		}
588
-	}
589
-
590
-	// traiter les parametres pas encore trouves
591
-	if ($v === null
592
-		and $args = func_get_args()
593
-		and count($args) == 2
594
-	) {
595
-		return $v_read; // rien trouve ou un tableau
596
-	} elseif ($testv) {
597
-		foreach ($ajouts as $k => $n) {
598
-			if (!is_array($v)) {
599
-				$url[] = $k . '=' . $u;
600
-			} else {
601
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
602
-				foreach ($v as $w) {
603
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
604
-				}
605
-			}
606
-		}
607
-	}
608
-
609
-	// eliminer les vides
610
-	$url = array_filter($url);
611
-
612
-	// recomposer l'adresse
613
-	if ($url) {
614
-		$a .= '?' . join($sep, $url);
615
-	}
616
-
617
-	return $a . $ancre;
529
+    // requete erronnee : plusieurs variable dans $c et aucun $v
530
+    if (strpos($c, "|") !== false and is_null($v)) {
531
+        return null;
532
+    }
533
+
534
+    // lever l'#ancre
535
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
536
+        $url = $r[1];
537
+        $ancre = $r[2];
538
+    } else {
539
+        $ancre = '';
540
+    }
541
+
542
+    // eclater
543
+    $url = preg_split(',[?]|&amp;|&,', $url);
544
+
545
+    // recuperer la base
546
+    $a = array_shift($url);
547
+    if (!$a) {
548
+        $a = './';
549
+    }
550
+
551
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
552
+    $ajouts = array_flip(explode('|', $c));
553
+    $u = is_array($v) ? $v : rawurlencode($v);
554
+    $testv = (is_array($v) ? count($v) : strlen($v));
555
+    $v_read = null;
556
+    // lire les variables et agir
557
+    foreach ($url as $n => $val) {
558
+        if (preg_match($regexp, urldecode($val), $r)) {
559
+            $r = array_pad($r, 3, null);
560
+            if ($v === null) {
561
+                // c'est un tableau, on memorise les valeurs
562
+                if (substr($r[1], -2) == "[]") {
563
+                    if (!$v_read) {
564
+                        $v_read = array();
565
+                    }
566
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
567
+                } // c'est un scalaire, on retourne direct
568
+                else {
569
+                    return $r[2] ? substr($r[2], 1) : '';
570
+                }
571
+            } // suppression
572
+            elseif (!$testv) {
573
+                unset($url[$n]);
574
+            }
575
+            // Ajout. Pour une variable, remplacer au meme endroit,
576
+            // pour un tableau ce sera fait dans la prochaine boucle
577
+            elseif (substr($r[1], -2) != '[]') {
578
+                $url[$n] = $r[1] . '=' . $u;
579
+                unset($ajouts[$r[1]]);
580
+            }
581
+            // Pour les tableaux on laisse tomber les valeurs de
582
+            // départ, on remplira à l'étape suivante
583
+            else {
584
+                unset($url[$n]);
585
+            }
586
+        }
587
+    }
588
+
589
+    // traiter les parametres pas encore trouves
590
+    if ($v === null
591
+        and $args = func_get_args()
592
+        and count($args) == 2
593
+    ) {
594
+        return $v_read; // rien trouve ou un tableau
595
+    } elseif ($testv) {
596
+        foreach ($ajouts as $k => $n) {
597
+            if (!is_array($v)) {
598
+                $url[] = $k . '=' . $u;
599
+            } else {
600
+                $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
601
+                foreach ($v as $w) {
602
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
603
+                }
604
+            }
605
+        }
606
+    }
607
+
608
+    // eliminer les vides
609
+    $url = array_filter($url);
610
+
611
+    // recomposer l'adresse
612
+    if ($url) {
613
+        $a .= '?' . join($sep, $url);
614
+    }
615
+
616
+    return $a . $ancre;
618 617
 }
619 618
 
620 619
 /**
@@ -632,21 +631,21 @@  discard block
 block discarded – undo
632 631
  * @return string
633 632
  */
634 633
 function ancre_url($url, $ancre) {
635
-	// lever l'#ancre
636
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
637
-		$url = $r[1];
638
-	}
639
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
640
-		if (!function_exists('translitteration')) {
641
-			include_spip('inc/charsets');
642
-		}
643
-		$ancre = preg_replace(
644
-			array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
645
-			array('', '-'),
646
-			translitteration($ancre)
647
-		);
648
-	}
649
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
634
+    // lever l'#ancre
635
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
636
+        $url = $r[1];
637
+    }
638
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
639
+        if (!function_exists('translitteration')) {
640
+            include_spip('inc/charsets');
641
+        }
642
+        $ancre = preg_replace(
643
+            array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
644
+            array('', '-'),
645
+            translitteration($ancre)
646
+        );
647
+    }
648
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
650 649
 }
651 650
 
652 651
 /**
@@ -656,16 +655,16 @@  discard block
 block discarded – undo
656 655
  * @return string
657 656
  */
658 657
 function nettoyer_uri($reset = null) {
659
-	static $done = false;
660
-	static $propre = '';
661
-	if (!is_null($reset)) {
662
-		return $propre = $reset;
663
-	}
664
-	if ($done) {
665
-		return $propre;
666
-	}
667
-	$done = true;
668
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
658
+    static $done = false;
659
+    static $propre = '';
660
+    if (!is_null($reset)) {
661
+        return $propre = $reset;
662
+    }
663
+    if ($done) {
664
+        return $propre;
665
+    }
666
+    $done = true;
667
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
669 668
 }
670 669
 
671 670
 /**
@@ -677,13 +676,13 @@  discard block
 block discarded – undo
677 676
  * @return string
678 677
  */
679 678
 function nettoyer_uri_var($request_uri) {
680
-	$uri1 = $request_uri;
681
-	do {
682
-		$uri = $uri1;
683
-		$uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
684
-			'\1', $uri);
685
-	} while ($uri <> $uri1);
686
-	return preg_replace(',[?&]$,', '', $uri1);
679
+    $uri1 = $request_uri;
680
+    do {
681
+        $uri = $uri1;
682
+        $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
683
+            '\1', $uri);
684
+    } while ($uri <> $uri1);
685
+    return preg_replace(',[?&]$,', '', $uri1);
687 686
 }
688 687
 
689 688
 
@@ -697,47 +696,47 @@  discard block
 block discarded – undo
697 696
  *    URL vers soi-même
698 697
  **/
699 698
 function self($amp = '&amp;', $root = false) {
700
-	$url = nettoyer_uri();
701
-	if (!$root
702
-		and (
703
-			// si pas de profondeur on peut tronquer
704
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
705
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
706
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
707
-	) {
708
-		$url = preg_replace(',^[^?]*/,', '', $url);
709
-	}
710
-	// ajouter le cas echeant les variables _POST['id_...']
711
-	foreach ($_POST as $v => $c) {
712
-		if (substr($v, 0, 3) == 'id_') {
713
-			$url = parametre_url($url, $v, $c, '&');
714
-		}
715
-	}
716
-
717
-	// supprimer les variables sans interet
718
-	if (test_espace_prive()) {
719
-		$url = preg_replace(',([?&])('
720
-			. 'lang|show_docs|'
721
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
722
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
723
-		$url = preg_replace(',[&]$,', '\1', $url);
724
-	}
725
-
726
-	// eviter les hacks
727
-	include_spip('inc/filtres_mini');
728
-	$url = spip_htmlspecialchars($url);
699
+    $url = nettoyer_uri();
700
+    if (!$root
701
+        and (
702
+            // si pas de profondeur on peut tronquer
703
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
704
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
705
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
706
+    ) {
707
+        $url = preg_replace(',^[^?]*/,', '', $url);
708
+    }
709
+    // ajouter le cas echeant les variables _POST['id_...']
710
+    foreach ($_POST as $v => $c) {
711
+        if (substr($v, 0, 3) == 'id_') {
712
+            $url = parametre_url($url, $v, $c, '&');
713
+        }
714
+    }
715
+
716
+    // supprimer les variables sans interet
717
+    if (test_espace_prive()) {
718
+        $url = preg_replace(',([?&])('
719
+            . 'lang|show_docs|'
720
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
721
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
722
+        $url = preg_replace(',[&]$,', '\1', $url);
723
+    }
724
+
725
+    // eviter les hacks
726
+    include_spip('inc/filtres_mini');
727
+    $url = spip_htmlspecialchars($url);
729 728
 	
730
-	$url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
729
+    $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
731 730
 
732
-	// &amp; ?
733
-	if ($amp != '&amp;') {
734
-		$url = str_replace('&amp;', $amp, $url);
735
-	}
731
+    // &amp; ?
732
+    if ($amp != '&amp;') {
733
+        $url = str_replace('&amp;', $amp, $url);
734
+    }
736 735
 
737
-	// Si ca demarre par ? ou vide, donner './'
738
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
736
+    // Si ca demarre par ? ou vide, donner './'
737
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
739 738
 
740
-	return $url;
739
+    return $url;
741 740
 }
742 741
 
743 742
 
@@ -748,7 +747,7 @@  discard block
 block discarded – undo
748 747
  *     true si c'est le cas, false sinon.
749 748
  */
750 749
 function test_espace_prive() {
751
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
750
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
752 751
 }
753 752
 
754 753
 /**
@@ -758,7 +757,7 @@  discard block
 block discarded – undo
758 757
  * @return bool
759 758
  */
760 759
 function test_plugin_actif($plugin) {
761
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
760
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
762 761
 }
763 762
 
764 763
 /**
@@ -789,51 +788,51 @@  discard block
 block discarded – undo
789 788
  *     Texte
790 789
  */
791 790
 function _T($texte, $args = array(), $options = array()) {
792
-	static $traduire = false;
793
-	$o = array('class' => '', 'force' => true, 'sanitize' => true);
794
-	if ($options) {
795
-		// support de l'ancien argument $class
796
-		if (is_string($options)) {
797
-			$options = array('class' => $options);
798
-		}
799
-		$o = array_merge($o, $options);
800
-	}
791
+    static $traduire = false;
792
+    $o = array('class' => '', 'force' => true, 'sanitize' => true);
793
+    if ($options) {
794
+        // support de l'ancien argument $class
795
+        if (is_string($options)) {
796
+            $options = array('class' => $options);
797
+        }
798
+        $o = array_merge($o, $options);
799
+    }
801 800
 
802
-	if (!$traduire) {
803
-		$traduire = charger_fonction('traduire', 'inc');
804
-		include_spip('inc/lang');
805
-	}
801
+    if (!$traduire) {
802
+        $traduire = charger_fonction('traduire', 'inc');
803
+        include_spip('inc/lang');
804
+    }
806 805
 
807
-	// On peut passer explicitement la langue dans le tableau
808
-	// On utilise le même nom de variable que la globale
809
-	if (isset($args['spip_lang'])) {
810
-		$lang = $args['spip_lang'];
811
-		// On l'enleve pour ne pas le passer au remplacement
812
-		unset($args['spip_lang']);
813
-	} // Sinon on prend la langue du contexte
814
-	else {
815
-		$lang = $GLOBALS['spip_lang'];
816
-	}
817
-	$text = $traduire($texte, $lang);
806
+    // On peut passer explicitement la langue dans le tableau
807
+    // On utilise le même nom de variable que la globale
808
+    if (isset($args['spip_lang'])) {
809
+        $lang = $args['spip_lang'];
810
+        // On l'enleve pour ne pas le passer au remplacement
811
+        unset($args['spip_lang']);
812
+    } // Sinon on prend la langue du contexte
813
+    else {
814
+        $lang = $GLOBALS['spip_lang'];
815
+    }
816
+    $text = $traduire($texte, $lang);
818 817
 
819
-	if (!strlen($text)) {
820
-		if (!$o['force']) {
821
-			return '';
822
-		}
818
+    if (!strlen($text)) {
819
+        if (!$o['force']) {
820
+            return '';
821
+        }
823 822
 
824
-		$text = $texte;
823
+        $text = $texte;
825 824
 
826
-		// pour les chaines non traduites, assurer un service minimum
827
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
828
-			$text = str_replace('_', ' ',
829
-				(($n = strpos($text, ':')) === false ? $texte :
830
-					substr($texte, $n + 1)));
831
-		}
832
-		$o['class'] = null;
825
+        // pour les chaines non traduites, assurer un service minimum
826
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
827
+            $text = str_replace('_', ' ',
828
+                (($n = strpos($text, ':')) === false ? $texte :
829
+                    substr($texte, $n + 1)));
830
+        }
831
+        $o['class'] = null;
833 832
 
834
-	}
833
+    }
835 834
 
836
-	return _L($text, $args, $o);
835
+    return _L($text, $args, $o);
837 836
 
838 837
 }
839 838
 
@@ -861,53 +860,53 @@  discard block
 block discarded – undo
861 860
  *     Texte
862 861
  */
863 862
 function _L($text, $args = array(), $options = array()) {
864
-	$f = $text;
865
-	$defaut_options = array(
866
-		'class' => null,
867
-		'sanitize' => true,
868
-	);
869
-	// support de l'ancien argument $class
870
-	if ($options and is_string($options)) {
871
-		$options = array('class' => $options);
872
-	}
873
-	if (is_array($options)) {
874
-		$options += $defaut_options;
875
-	} else {
876
-		$options = $defaut_options;
877
-	}
878
-
879
-	if (is_array($args) and count($args)) {
880
-		if (!function_exists('interdire_scripts')) {
881
-			include_spip('inc/texte');
882
-		}
883
-		if (!function_exists('echapper_html_suspect')) {
884
-			include_spip('inc/texte_mini');
885
-		}
886
-		foreach ($args as $name => $value) {
887
-			if (strpos($text, "@$name@") !== false) {
888
-				if ($options['sanitize']) {
889
-					$value = echapper_html_suspect($value);
890
-					$value = interdire_scripts($value, -1);
891
-				}
892
-				if (!empty($options['class'])) {
893
-					$value = "<span class='".$options['class']."'>$value</span>";
894
-				}
895
-				$text = str_replace("@$name@", $value, $text);
896
-				unset($args[$name]);
897
-			}
898
-		}
899
-		// Si des variables n'ont pas ete inserees, le signaler
900
-		// (chaines de langues pas a jour)
901
-		if ($args) {
902
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
903
-		}
904
-	}
905
-
906
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
907
-		return "<span class=debug-traduction-erreur>$text</span>";
908
-	} else {
909
-		return $text;
910
-	}
863
+    $f = $text;
864
+    $defaut_options = array(
865
+        'class' => null,
866
+        'sanitize' => true,
867
+    );
868
+    // support de l'ancien argument $class
869
+    if ($options and is_string($options)) {
870
+        $options = array('class' => $options);
871
+    }
872
+    if (is_array($options)) {
873
+        $options += $defaut_options;
874
+    } else {
875
+        $options = $defaut_options;
876
+    }
877
+
878
+    if (is_array($args) and count($args)) {
879
+        if (!function_exists('interdire_scripts')) {
880
+            include_spip('inc/texte');
881
+        }
882
+        if (!function_exists('echapper_html_suspect')) {
883
+            include_spip('inc/texte_mini');
884
+        }
885
+        foreach ($args as $name => $value) {
886
+            if (strpos($text, "@$name@") !== false) {
887
+                if ($options['sanitize']) {
888
+                    $value = echapper_html_suspect($value);
889
+                    $value = interdire_scripts($value, -1);
890
+                }
891
+                if (!empty($options['class'])) {
892
+                    $value = "<span class='".$options['class']."'>$value</span>";
893
+                }
894
+                $text = str_replace("@$name@", $value, $text);
895
+                unset($args[$name]);
896
+            }
897
+        }
898
+        // Si des variables n'ont pas ete inserees, le signaler
899
+        // (chaines de langues pas a jour)
900
+        if ($args) {
901
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
902
+        }
903
+    }
904
+
905
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
906
+        return "<span class=debug-traduction-erreur>$text</span>";
907
+    } else {
908
+        return $text;
909
+    }
911 910
 }
912 911
 
913 912
 
@@ -921,13 +920,13 @@  discard block
 block discarded – undo
921 920
  * @return string
922 921
  */
923 922
 function joli_repertoire($rep) {
924
-	$a = substr($rep, 0, 1);
925
-	if ($a <> '.' and $a <> '/') {
926
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
927
-	}
928
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
923
+    $a = substr($rep, 0, 1);
924
+    if ($a <> '.' and $a <> '/') {
925
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
926
+    }
927
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
929 928
 
930
-	return $rep;
929
+    return $rep;
931 930
 }
932 931
 
933 932
 
@@ -952,33 +951,33 @@  discard block
 block discarded – undo
952 951
  * @return float|int|string|void
953 952
  */
954 953
 function spip_timer($t = 'rien', $raw = false) {
955
-	static $time;
956
-	$a = time();
957
-	$b = microtime();
958
-	// microtime peut contenir les microsecondes et le temps
959
-	$b = explode(' ', $b);
960
-	if (count($b) == 2) {
961
-		$a = end($b);
962
-	} // plus precis !
963
-	$b = reset($b);
964
-	if (!isset($time[$t])) {
965
-		$time[$t] = $a + $b;
966
-	} else {
967
-		$p = ($a + $b - $time[$t]) * 1000;
968
-		unset($time[$t]);
954
+    static $time;
955
+    $a = time();
956
+    $b = microtime();
957
+    // microtime peut contenir les microsecondes et le temps
958
+    $b = explode(' ', $b);
959
+    if (count($b) == 2) {
960
+        $a = end($b);
961
+    } // plus precis !
962
+    $b = reset($b);
963
+    if (!isset($time[$t])) {
964
+        $time[$t] = $a + $b;
965
+    } else {
966
+        $p = ($a + $b - $time[$t]) * 1000;
967
+        unset($time[$t]);
969 968
 #			echo "'$p'";exit;
970
-		if ($raw) {
971
-			return $p;
972
-		}
973
-		if ($p < 1000) {
974
-			$s = '';
975
-		} else {
976
-			$s = sprintf("%d ", $x = floor($p / 1000));
977
-			$p -= ($x * 1000);
978
-		}
969
+        if ($raw) {
970
+            return $p;
971
+        }
972
+        if ($p < 1000) {
973
+            $s = '';
974
+        } else {
975
+            $s = sprintf("%d ", $x = floor($p / 1000));
976
+            $p -= ($x * 1000);
977
+        }
979 978
 
980
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
981
-	}
979
+        return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
980
+    }
982 981
 }
983 982
 
984 983
 
@@ -986,21 +985,21 @@  discard block
 block discarded – undo
986 985
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
987 986
 // https://code.spip.net/@spip_touch
988 987
 function spip_touch($fichier, $duree = 0, $touch = true) {
989
-	if ($duree) {
990
-		clearstatcache();
991
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
992
-			return false;
993
-		}
994
-	}
995
-	if ($touch !== false) {
996
-		if (!@touch($fichier)) {
997
-			spip_unlink($fichier);
998
-			@touch($fichier);
999
-		};
1000
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1001
-	}
988
+    if ($duree) {
989
+        clearstatcache();
990
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
991
+            return false;
992
+        }
993
+    }
994
+    if ($touch !== false) {
995
+        if (!@touch($fichier)) {
996
+            spip_unlink($fichier);
997
+            @touch($fichier);
998
+        };
999
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1000
+    }
1002 1001
 
1003
-	return true;
1002
+    return true;
1004 1003
 }
1005 1004
 
1006 1005
 
@@ -1012,11 +1011,11 @@  discard block
 block discarded – undo
1012 1011
  * @uses cron()
1013 1012
  **/
1014 1013
 function action_cron() {
1015
-	include_spip('inc/headers');
1016
-	http_status(204); // No Content
1017
-	header("Connection: close");
1018
-	define('_DIRECT_CRON_FORCE', true);
1019
-	cron();
1014
+    include_spip('inc/headers');
1015
+    http_status(204); // No Content
1016
+    header("Connection: close");
1017
+    define('_DIRECT_CRON_FORCE', true);
1018
+    cron();
1020 1019
 }
1021 1020
 
1022 1021
 /**
@@ -1032,26 +1031,26 @@  discard block
 block discarded – undo
1032 1031
  *     True si la tache a pu être effectuée
1033 1032
  */
1034 1033
 function cron($taches = array(), $taches_old = array()) {
1035
-	// si pas en mode cron force, laisser tomber.
1036
-	if (!defined('_DIRECT_CRON_FORCE')) {
1037
-		return false;
1038
-	}
1039
-	if (!is_array($taches)) {
1040
-		$taches = $taches_old;
1041
-	} // compat anciens appels
1042
-	// si taches a inserer en base et base inaccessible, laisser tomber
1043
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1044
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1045
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1046
-	if ($taches and count($taches) and !spip_connect()) {
1047
-		return false;
1048
-	}
1049
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1050
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1051
-		return $genie($taches);
1052
-	}
1053
-
1054
-	return false;
1034
+    // si pas en mode cron force, laisser tomber.
1035
+    if (!defined('_DIRECT_CRON_FORCE')) {
1036
+        return false;
1037
+    }
1038
+    if (!is_array($taches)) {
1039
+        $taches = $taches_old;
1040
+    } // compat anciens appels
1041
+    // si taches a inserer en base et base inaccessible, laisser tomber
1042
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1043
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1044
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1045
+    if ($taches and count($taches) and !spip_connect()) {
1046
+        return false;
1047
+    }
1048
+    spip_log("cron !", 'jq' . _LOG_DEBUG);
1049
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1050
+        return $genie($taches);
1051
+    }
1052
+
1053
+    return false;
1055 1054
 }
1056 1055
 
1057 1056
 /**
@@ -1083,17 +1082,17 @@  discard block
 block discarded – undo
1083 1082
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1084 1083
  */
1085 1084
 function job_queue_add(
1086
-	$function,
1087
-	$description,
1088
-	$arguments = array(),
1089
-	$file = '',
1090
-	$no_duplicate = false,
1091
-	$time = 0,
1092
-	$priority = 0
1085
+    $function,
1086
+    $description,
1087
+    $arguments = array(),
1088
+    $file = '',
1089
+    $no_duplicate = false,
1090
+    $time = 0,
1091
+    $priority = 0
1093 1092
 ) {
1094
-	include_spip('inc/queue');
1093
+    include_spip('inc/queue');
1095 1094
 
1096
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1095
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1097 1096
 }
1098 1097
 
1099 1098
 /**
@@ -1104,9 +1103,9 @@  discard block
 block discarded – undo
1104 1103
  * @return bool
1105 1104
  */
1106 1105
 function job_queue_remove($id_job) {
1107
-	include_spip('inc/queue');
1106
+    include_spip('inc/queue');
1108 1107
 
1109
-	return queue_remove_job($id_job);
1108
+    return queue_remove_job($id_job);
1110 1109
 }
1111 1110
 
1112 1111
 /**
@@ -1119,9 +1118,9 @@  discard block
 block discarded – undo
1119 1118
  *     or an array of simple array to link multiples objet in one time
1120 1119
  */
1121 1120
 function job_queue_link($id_job, $objets) {
1122
-	include_spip('inc/queue');
1121
+    include_spip('inc/queue');
1123 1122
 
1124
-	return queue_link_job($id_job, $objets);
1123
+    return queue_link_job($id_job, $objets);
1125 1124
 }
1126 1125
 
1127 1126
 
@@ -1141,36 +1140,36 @@  discard block
 block discarded – undo
1141 1140
  *  - `null` si la queue n'est pas encore initialisée
1142 1141
  */
1143 1142
 function queue_sleep_time_to_next_job($force = null) {
1144
-	static $queue_next_job_time = -1;
1145
-	if ($force === true) {
1146
-		$queue_next_job_time = -1;
1147
-	} elseif ($force) {
1148
-		$queue_next_job_time = $force;
1149
-	}
1150
-
1151
-	if ($queue_next_job_time == -1) {
1152
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1153
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1154
-		}
1155
-		// utiliser un cache memoire si dispo
1156
-		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1157
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1158
-		} else {
1159
-			$queue_next_job_time = null;
1160
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1161
-				$queue_next_job_time = intval($contenu);
1162
-			}
1163
-		}
1164
-	}
1165
-
1166
-	if (is_null($queue_next_job_time)) {
1167
-		return null;
1168
-	}
1169
-	if (!$_SERVER['REQUEST_TIME']) {
1170
-		$_SERVER['REQUEST_TIME'] = time();
1171
-	}
1172
-
1173
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1143
+    static $queue_next_job_time = -1;
1144
+    if ($force === true) {
1145
+        $queue_next_job_time = -1;
1146
+    } elseif ($force) {
1147
+        $queue_next_job_time = $force;
1148
+    }
1149
+
1150
+    if ($queue_next_job_time == -1) {
1151
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1152
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1153
+        }
1154
+        // utiliser un cache memoire si dispo
1155
+        if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1156
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1157
+        } else {
1158
+            $queue_next_job_time = null;
1159
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1160
+                $queue_next_job_time = intval($contenu);
1161
+            }
1162
+        }
1163
+    }
1164
+
1165
+    if (is_null($queue_next_job_time)) {
1166
+        return null;
1167
+    }
1168
+    if (!$_SERVER['REQUEST_TIME']) {
1169
+        $_SERVER['REQUEST_TIME'] = time();
1170
+    }
1171
+
1172
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1174 1173
 }
1175 1174
 
1176 1175
 
@@ -1182,9 +1181,9 @@  discard block
 block discarded – undo
1182 1181
  * @return string
1183 1182
  */
1184 1183
 function quote_amp($u) {
1185
-	return preg_replace(
1186
-		"/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1187
-		"&amp;", $u);
1184
+    return preg_replace(
1185
+        "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1186
+        "&amp;", $u);
1188 1187
 }
1189 1188
 
1190 1189
 
@@ -1207,27 +1206,27 @@  discard block
 block discarded – undo
1207 1206
  *     Balise HTML `<script>` et son contenu
1208 1207
  **/
1209 1208
 function http_script($script, $src = '', $noscript = '') {
1210
-	static $done = array();
1209
+    static $done = array();
1211 1210
 
1212
-	if ($src && !isset($done[$src])) {
1213
-		$done[$src] = true;
1214
-		$src = find_in_path($src, _JAVASCRIPT);
1215
-		$src = " src='$src'";
1216
-	} else {
1217
-		$src = '';
1218
-	}
1219
-	if ($script) {
1220
-		$script = ("/*<![CDATA[*/\n" .
1221
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1222
-			"/*]]>*/");
1223
-	}
1224
-	if ($noscript) {
1225
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1226
-	}
1211
+    if ($src && !isset($done[$src])) {
1212
+        $done[$src] = true;
1213
+        $src = find_in_path($src, _JAVASCRIPT);
1214
+        $src = " src='$src'";
1215
+    } else {
1216
+        $src = '';
1217
+    }
1218
+    if ($script) {
1219
+        $script = ("/*<![CDATA[*/\n" .
1220
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1221
+            "/*]]>*/");
1222
+    }
1223
+    if ($noscript) {
1224
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1225
+    }
1227 1226
 
1228
-	return ($src or $script or $noscript)
1229
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1230
-		: '';
1227
+    return ($src or $script or $noscript)
1228
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1229
+        : '';
1231 1230
 }
1232 1231
 
1233 1232
 
@@ -1262,7 +1261,7 @@  discard block
 block discarded – undo
1262 1261
  *     Texte échappé
1263 1262
  **/
1264 1263
 function texte_script($texte) {
1265
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1264
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1266 1265
 }
1267 1266
 
1268 1267
 
@@ -1299,69 +1298,69 @@  discard block
 block discarded – undo
1299 1298
  *     Liste des chemins, par ordre de priorité.
1300 1299
  **/
1301 1300
 function _chemin($dir_path = null) {
1302
-	static $path_base = null;
1303
-	static $path_full = null;
1304
-	if ($path_base == null) {
1305
-		// Chemin standard depuis l'espace public
1306
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1307
-			_DIR_RACINE . ':' .
1308
-			_DIR_RACINE . 'squelettes-dist/:' .
1309
-			_DIR_RACINE . 'prive/:' .
1310
-			_DIR_RESTREINT;
1311
-		// Ajouter squelettes/
1312
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1313
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1314
-		}
1315
-		foreach (explode(':', $path) as $dir) {
1316
-			if (strlen($dir) and substr($dir, -1) != '/') {
1317
-				$dir .= "/";
1318
-			}
1319
-			$path_base[] = $dir;
1320
-		}
1321
-		$path_full = $path_base;
1322
-		// Et le(s) dossier(s) des squelettes nommes
1323
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1324
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1325
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1326
-			}
1327
-		}
1328
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1329
-	}
1330
-	if ($dir_path === null) {
1331
-		return $path_full;
1332
-	}
1333
-
1334
-	if (strlen($dir_path)) {
1335
-		$tete = "";
1336
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1337
-			$tete = array_shift($path_base);
1338
-		}
1339
-		$dirs = array_reverse(explode(':', $dir_path));
1340
-		foreach ($dirs as $dir_path) {
1341
-			#if ($dir_path{0}!='/')
1342
-			#	$dir_path = $dir_path;
1343
-			if (substr($dir_path, -1) != '/') {
1344
-				$dir_path .= "/";
1345
-			}
1346
-			if (!in_array($dir_path, $path_base)) {
1347
-				array_unshift($path_base, $dir_path);
1348
-			}
1349
-		}
1350
-		if (strlen($tete)) {
1351
-			array_unshift($path_base, $tete);
1352
-		}
1353
-	}
1354
-	$path_full = $path_base;
1355
-	// Et le(s) dossier(s) des squelettes nommes
1356
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1357
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1358
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1359
-		}
1360
-	}
1361
-
1362
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1363
-
1364
-	return $path_full;
1301
+    static $path_base = null;
1302
+    static $path_full = null;
1303
+    if ($path_base == null) {
1304
+        // Chemin standard depuis l'espace public
1305
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1306
+            _DIR_RACINE . ':' .
1307
+            _DIR_RACINE . 'squelettes-dist/:' .
1308
+            _DIR_RACINE . 'prive/:' .
1309
+            _DIR_RESTREINT;
1310
+        // Ajouter squelettes/
1311
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1312
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1313
+        }
1314
+        foreach (explode(':', $path) as $dir) {
1315
+            if (strlen($dir) and substr($dir, -1) != '/') {
1316
+                $dir .= "/";
1317
+            }
1318
+            $path_base[] = $dir;
1319
+        }
1320
+        $path_full = $path_base;
1321
+        // Et le(s) dossier(s) des squelettes nommes
1322
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1323
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1324
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1325
+            }
1326
+        }
1327
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1328
+    }
1329
+    if ($dir_path === null) {
1330
+        return $path_full;
1331
+    }
1332
+
1333
+    if (strlen($dir_path)) {
1334
+        $tete = "";
1335
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1336
+            $tete = array_shift($path_base);
1337
+        }
1338
+        $dirs = array_reverse(explode(':', $dir_path));
1339
+        foreach ($dirs as $dir_path) {
1340
+            #if ($dir_path{0}!='/')
1341
+            #	$dir_path = $dir_path;
1342
+            if (substr($dir_path, -1) != '/') {
1343
+                $dir_path .= "/";
1344
+            }
1345
+            if (!in_array($dir_path, $path_base)) {
1346
+                array_unshift($path_base, $dir_path);
1347
+            }
1348
+        }
1349
+        if (strlen($tete)) {
1350
+            array_unshift($path_base, $tete);
1351
+        }
1352
+    }
1353
+    $path_full = $path_base;
1354
+    // Et le(s) dossier(s) des squelettes nommes
1355
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1356
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1357
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1358
+        }
1359
+    }
1360
+
1361
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1362
+
1363
+    return $path_full;
1365 1364
 }
1366 1365
 
1367 1366
 /**
@@ -1374,76 +1373,76 @@  discard block
 block discarded – undo
1374 1373
  * @return array Liste de chemins
1375 1374
  **/
1376 1375
 function creer_chemin() {
1377
-	$path_a = _chemin();
1378
-	static $c = '';
1376
+    $path_a = _chemin();
1377
+    static $c = '';
1379 1378
 
1380
-	// on calcule le chemin si le dossier skel a change
1381
-	if ($c != $GLOBALS['dossier_squelettes']) {
1382
-		// assurer le non plantage lors de la montee de version :
1383
-		$c = $GLOBALS['dossier_squelettes'];
1384
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1385
-	}
1379
+    // on calcule le chemin si le dossier skel a change
1380
+    if ($c != $GLOBALS['dossier_squelettes']) {
1381
+        // assurer le non plantage lors de la montee de version :
1382
+        $c = $GLOBALS['dossier_squelettes'];
1383
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1384
+    }
1386 1385
 
1387
-	return $path_a;
1386
+    return $path_a;
1388 1387
 }
1389 1388
 
1390 1389
 
1391 1390
 function lister_themes_prives() {
1392
-	static $themes = null;
1393
-	if (is_null($themes)) {
1394
-		// si pas encore definie
1395
-		if (!defined('_SPIP_THEME_PRIVE')) {
1396
-			define('_SPIP_THEME_PRIVE', 'spip');
1397
-		}
1398
-		$themes = array(_SPIP_THEME_PRIVE);
1399
-		// lors d'une installation neuve, prefs n'est pas definie.
1400
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1401
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1402
-		} else {
1403
-			$prefs = array();
1404
-		}
1405
-		if (is_string($prefs)) {
1406
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1407
-		}
1408
-		if (
1409
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1410
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1411
-			and $theme != _SPIP_THEME_PRIVE
1412
-		) {
1413
-			array_unshift($themes, $theme);
1414
-		} // placer le theme choisi en tete
1415
-	}
1416
-
1417
-	return $themes;
1391
+    static $themes = null;
1392
+    if (is_null($themes)) {
1393
+        // si pas encore definie
1394
+        if (!defined('_SPIP_THEME_PRIVE')) {
1395
+            define('_SPIP_THEME_PRIVE', 'spip');
1396
+        }
1397
+        $themes = array(_SPIP_THEME_PRIVE);
1398
+        // lors d'une installation neuve, prefs n'est pas definie.
1399
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1400
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1401
+        } else {
1402
+            $prefs = array();
1403
+        }
1404
+        if (is_string($prefs)) {
1405
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1406
+        }
1407
+        if (
1408
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1409
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1410
+            and $theme != _SPIP_THEME_PRIVE
1411
+        ) {
1412
+            array_unshift($themes, $theme);
1413
+        } // placer le theme choisi en tete
1414
+    }
1415
+
1416
+    return $themes;
1418 1417
 }
1419 1418
 
1420 1419
 function find_in_theme($file, $subdir = '', $include = false) {
1421
-	static $themefiles = array();
1422
-	if (isset($themefiles["$subdir$file"])) {
1423
-		return $themefiles["$subdir$file"];
1424
-	}
1425
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1426
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1427
-	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1428
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1429
-		and $f = find_in_theme("$file_svg_generique")) {
1430
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1431
-			return $themefiles["$subdir$file"] = $fsize;
1432
-		}
1433
-		else {
1434
-			return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1435
-		}
1436
-	}
1437
-
1438
-	$themes = lister_themes_prives();
1439
-	foreach ($themes as $theme) {
1440
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1441
-			return $themefiles["$subdir$file"] = $f;
1442
-		}
1443
-	}
1444
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1445
-
1446
-	return $themefiles["$subdir$file"] = "";
1420
+    static $themefiles = array();
1421
+    if (isset($themefiles["$subdir$file"])) {
1422
+        return $themefiles["$subdir$file"];
1423
+    }
1424
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1425
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1426
+    if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1427
+      and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1428
+        and $f = find_in_theme("$file_svg_generique")) {
1429
+        if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1430
+            return $themefiles["$subdir$file"] = $fsize;
1431
+        }
1432
+        else {
1433
+            return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1434
+        }
1435
+    }
1436
+
1437
+    $themes = lister_themes_prives();
1438
+    foreach ($themes as $theme) {
1439
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1440
+            return $themefiles["$subdir$file"] = $f;
1441
+        }
1442
+    }
1443
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1444
+
1445
+    return $themefiles["$subdir$file"] = "";
1447 1446
 }
1448 1447
 
1449 1448
 
@@ -1467,31 +1466,31 @@  discard block
 block discarded – undo
1467 1466
  *     sinon chaîne vide.
1468 1467
  **/
1469 1468
 function chemin_image($icone) {
1470
-	static $icone_renommer;
1471
-	if ($p = strpos($icone, '?')) {
1472
-		$icone = substr($icone,0, $p);
1473
-	}
1474
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1475
-	if (strpos($icone, "/") !== false and file_exists($icone)) {
1476
-		return $icone;
1477
-	}
1478
-
1479
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1480
-	if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1481
-		return $f;
1482
-	}
1483
-	// sinon passer par le module de renommage
1484
-	if (is_null($icone_renommer)) {
1485
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1486
-	}
1487
-	if ($icone_renommer) {
1488
-		list($icone, $fonction) = $icone_renommer($icone, "");
1489
-		if (file_exists($icone)) {
1490
-			return $icone;
1491
-		}
1492
-	}
1493
-
1494
-	return find_in_path($icone, _NOM_IMG_PACK);
1469
+    static $icone_renommer;
1470
+    if ($p = strpos($icone, '?')) {
1471
+        $icone = substr($icone,0, $p);
1472
+    }
1473
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1474
+    if (strpos($icone, "/") !== false and file_exists($icone)) {
1475
+        return $icone;
1476
+    }
1477
+
1478
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1479
+    if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1480
+        return $f;
1481
+    }
1482
+    // sinon passer par le module de renommage
1483
+    if (is_null($icone_renommer)) {
1484
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1485
+    }
1486
+    if ($icone_renommer) {
1487
+        list($icone, $fonction) = $icone_renommer($icone, "");
1488
+        if (file_exists($icone)) {
1489
+            return $icone;
1490
+        }
1491
+    }
1492
+
1493
+    return find_in_path($icone, _NOM_IMG_PACK);
1495 1494
 }
1496 1495
 
1497 1496
 //
@@ -1529,127 +1528,127 @@  discard block
 block discarded – undo
1529 1528
  *     - false : fichier introuvable
1530 1529
  **/
1531 1530
 function find_in_path($file, $dirname = '', $include = false) {
1532
-	static $dirs = array();
1533
-	static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1534
-	static $c = '';
1535
-
1536
-	if (!$file and !strlen($file)) {
1537
-		return false;
1538
-	}
1539
-
1540
-	// on calcule le chemin si le dossier skel a change
1541
-	if ($c != $GLOBALS['dossier_squelettes']) {
1542
-		// assurer le non plantage lors de la montee de version :
1543
-		$c = $GLOBALS['dossier_squelettes'];
1544
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1545
-	}
1546
-
1547
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1548
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1549
-			return false;
1550
-		}
1551
-		if ($include and !isset($inc[$dirname][$file])) {
1552
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1553
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1554
-		}
1555
-
1556
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1557
-	}
1558
-
1559
-	$a = strrpos($file, '/');
1560
-	if ($a !== false) {
1561
-		$dirname .= substr($file, 0, ++$a);
1562
-		$file = substr($file, $a);
1563
-	}
1564
-
1565
-	foreach (creer_chemin() as $dir) {
1566
-		if (!isset($dirs[$a = $dir . $dirname])) {
1567
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1568
-		}
1569
-		if ($dirs[$a]) {
1570
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1571
-				if ($include and !isset($inc[$dirname][$file])) {
1572
-					include_once _ROOT_CWD . $a;
1573
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1574
-				}
1575
-				if (!defined('_SAUVER_CHEMIN')) {
1576
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1577
-					if (is_null($GLOBALS['path_files'])) {
1578
-						return $a;
1579
-					}
1580
-					define('_SAUVER_CHEMIN', true);
1581
-				}
1582
-
1583
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1584
-			}
1585
-		}
1586
-	}
1587
-
1588
-	if ($include) {
1589
-		spip_log("include_spip $dirname$file non trouve");
1590
-		if ($include === 'required') {
1591
-			echo '<pre>',
1592
-			"<strong>Erreur Fatale</strong><br />";
1593
-			if (function_exists('debug_print_backtrace')) {
1594
-				echo debug_print_backtrace();
1595
-			}
1596
-			echo '</pre>';
1597
-			die("Erreur interne: ne peut inclure $dirname$file");
1598
-		}
1599
-	}
1600
-
1601
-	if (!defined('_SAUVER_CHEMIN')) {
1602
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1603
-		if (is_null($GLOBALS['path_files'])) {
1604
-			return false;
1605
-		}
1606
-		define('_SAUVER_CHEMIN', true);
1607
-	}
1608
-
1609
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1531
+    static $dirs = array();
1532
+    static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1533
+    static $c = '';
1534
+
1535
+    if (!$file and !strlen($file)) {
1536
+        return false;
1537
+    }
1538
+
1539
+    // on calcule le chemin si le dossier skel a change
1540
+    if ($c != $GLOBALS['dossier_squelettes']) {
1541
+        // assurer le non plantage lors de la montee de version :
1542
+        $c = $GLOBALS['dossier_squelettes'];
1543
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1544
+    }
1545
+
1546
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1547
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1548
+            return false;
1549
+        }
1550
+        if ($include and !isset($inc[$dirname][$file])) {
1551
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1552
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1553
+        }
1554
+
1555
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1556
+    }
1557
+
1558
+    $a = strrpos($file, '/');
1559
+    if ($a !== false) {
1560
+        $dirname .= substr($file, 0, ++$a);
1561
+        $file = substr($file, $a);
1562
+    }
1563
+
1564
+    foreach (creer_chemin() as $dir) {
1565
+        if (!isset($dirs[$a = $dir . $dirname])) {
1566
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1567
+        }
1568
+        if ($dirs[$a]) {
1569
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1570
+                if ($include and !isset($inc[$dirname][$file])) {
1571
+                    include_once _ROOT_CWD . $a;
1572
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1573
+                }
1574
+                if (!defined('_SAUVER_CHEMIN')) {
1575
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1576
+                    if (is_null($GLOBALS['path_files'])) {
1577
+                        return $a;
1578
+                    }
1579
+                    define('_SAUVER_CHEMIN', true);
1580
+                }
1581
+
1582
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1583
+            }
1584
+        }
1585
+    }
1586
+
1587
+    if ($include) {
1588
+        spip_log("include_spip $dirname$file non trouve");
1589
+        if ($include === 'required') {
1590
+            echo '<pre>',
1591
+            "<strong>Erreur Fatale</strong><br />";
1592
+            if (function_exists('debug_print_backtrace')) {
1593
+                echo debug_print_backtrace();
1594
+            }
1595
+            echo '</pre>';
1596
+            die("Erreur interne: ne peut inclure $dirname$file");
1597
+        }
1598
+    }
1599
+
1600
+    if (!defined('_SAUVER_CHEMIN')) {
1601
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1602
+        if (is_null($GLOBALS['path_files'])) {
1603
+            return false;
1604
+        }
1605
+        define('_SAUVER_CHEMIN', true);
1606
+    }
1607
+
1608
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1610 1609
 }
1611 1610
 
1612 1611
 function clear_path_cache() {
1613
-	$GLOBALS['path_files'] = array();
1614
-	spip_unlink(_CACHE_CHEMIN);
1612
+    $GLOBALS['path_files'] = array();
1613
+    spip_unlink(_CACHE_CHEMIN);
1615 1614
 }
1616 1615
 
1617 1616
 function load_path_cache() {
1618
-	// charger le path des plugins
1619
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1620
-		include_once(_CACHE_PLUGINS_PATH);
1621
-	}
1622
-	$GLOBALS['path_files'] = array();
1623
-	// si le visiteur est admin,
1624
-	// on ne recharge pas le cache pour forcer sa mise a jour
1625
-	if (
1626
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1627
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1628
-		// utiliser le cookie est un pis aller qui marche 'en general'
1629
-		// on blinde par un second test au moment de la lecture de la session
1630
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1631
-		// et en ignorant ce cache en cas de recalcul explicite
1632
-	!_request('var_mode')
1633
-	) {
1634
-		// on essaye de lire directement sans verrou pour aller plus vite
1635
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1636
-			// mais si semble corrompu on relit avec un verrou
1637
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1638
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1639
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1640
-					$GLOBALS['path_files'] = array();
1641
-				}
1642
-			}
1643
-		}
1644
-	}
1617
+    // charger le path des plugins
1618
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1619
+        include_once(_CACHE_PLUGINS_PATH);
1620
+    }
1621
+    $GLOBALS['path_files'] = array();
1622
+    // si le visiteur est admin,
1623
+    // on ne recharge pas le cache pour forcer sa mise a jour
1624
+    if (
1625
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1626
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1627
+        // utiliser le cookie est un pis aller qui marche 'en general'
1628
+        // on blinde par un second test au moment de la lecture de la session
1629
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1630
+        // et en ignorant ce cache en cas de recalcul explicite
1631
+    !_request('var_mode')
1632
+    ) {
1633
+        // on essaye de lire directement sans verrou pour aller plus vite
1634
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1635
+            // mais si semble corrompu on relit avec un verrou
1636
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1637
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1638
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1639
+                    $GLOBALS['path_files'] = array();
1640
+                }
1641
+            }
1642
+        }
1643
+    }
1645 1644
 }
1646 1645
 
1647 1646
 function save_path_cache() {
1648
-	if (defined('_SAUVER_CHEMIN')
1649
-		and _SAUVER_CHEMIN
1650
-	) {
1651
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1652
-	}
1647
+    if (defined('_SAUVER_CHEMIN')
1648
+        and _SAUVER_CHEMIN
1649
+    ) {
1650
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1651
+    }
1653 1652
 }
1654 1653
 
1655 1654
 
@@ -1669,33 +1668,33 @@  discard block
 block discarded – undo
1669 1668
  * @return array
1670 1669
  */
1671 1670
 function find_all_in_path($dir, $pattern, $recurs = false) {
1672
-	$liste_fichiers = array();
1673
-	$maxfiles = 10000;
1674
-
1675
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1676
-	// on a pas encore inclus flock.php
1677
-	if (!function_exists('preg_files')) {
1678
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1679
-	}
1680
-
1681
-	// Parcourir le chemin
1682
-	foreach (creer_chemin() as $d) {
1683
-		$f = $d . $dir;
1684
-		if (@is_dir($f)) {
1685
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1686
-			foreach ($liste as $chemin) {
1687
-				$nom = basename($chemin);
1688
-				// ne prendre que les fichiers pas deja trouves
1689
-				// car find_in_path prend le premier qu'il trouve,
1690
-				// les autres sont donc masques
1691
-				if (!isset($liste_fichiers[$nom])) {
1692
-					$liste_fichiers[$nom] = $chemin;
1693
-				}
1694
-			}
1695
-		}
1696
-	}
1697
-
1698
-	return $liste_fichiers;
1671
+    $liste_fichiers = array();
1672
+    $maxfiles = 10000;
1673
+
1674
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1675
+    // on a pas encore inclus flock.php
1676
+    if (!function_exists('preg_files')) {
1677
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1678
+    }
1679
+
1680
+    // Parcourir le chemin
1681
+    foreach (creer_chemin() as $d) {
1682
+        $f = $d . $dir;
1683
+        if (@is_dir($f)) {
1684
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1685
+            foreach ($liste as $chemin) {
1686
+                $nom = basename($chemin);
1687
+                // ne prendre que les fichiers pas deja trouves
1688
+                // car find_in_path prend le premier qu'il trouve,
1689
+                // les autres sont donc masques
1690
+                if (!isset($liste_fichiers[$nom])) {
1691
+                    $liste_fichiers[$nom] = $chemin;
1692
+                }
1693
+            }
1694
+        }
1695
+    }
1696
+
1697
+    return $liste_fichiers;
1699 1698
 }
1700 1699
 
1701 1700
 /**
@@ -1707,17 +1706,17 @@  discard block
 block discarded – undo
1707 1706
  * @return bool
1708 1707
  */
1709 1708
 function autoriser_sans_cookie($nom, $strict = false) {
1710
-	static $autsanscookie = array('install', 'base_repair');
1709
+    static $autsanscookie = array('install', 'base_repair');
1711 1710
 
1712
-	if (in_array($nom, $autsanscookie)) {
1713
-		if (test_espace_prive()){
1714
-			include_spip('base/connect_sql');
1715
-			if (!$strict or !spip_connect()){
1716
-				return true;
1717
-			}
1718
-		}
1719
-	}
1720
-	return false;
1711
+    if (in_array($nom, $autsanscookie)) {
1712
+        if (test_espace_prive()){
1713
+            include_spip('base/connect_sql');
1714
+            if (!$strict or !spip_connect()){
1715
+                return true;
1716
+            }
1717
+        }
1718
+    }
1719
+    return false;
1721 1720
 }
1722 1721
 
1723 1722
 /**
@@ -1743,99 +1742,99 @@  discard block
 block discarded – undo
1743 1742
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1744 1743
  */
1745 1744
 function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1746
-	if ($public === null) {
1747
-		$public = !test_espace_prive();
1748
-	}
1749
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1750
-
1751
-	if (!$public) {
1752
-		if (!$entite) {
1753
-			return '';
1754
-		}
1755
-		if (!function_exists('generer_url_ecrire_objet')) {
1756
-			include_spip('inc/urls');
1757
-		}
1758
-		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1759
-	} else {
1760
-		if ($type === null) {
1761
-			$type = (isset($GLOBALS['type_urls']))
1762
-				? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1763
-				: ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1764
-					? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1765
-		}
1766
-
1767
-		$f = charger_fonction($type, 'urls', true);
1768
-		// se rabattre sur les urls page si les urls perso non dispo
1769
-		if (!$f) {
1770
-			$f = charger_fonction('page', 'urls', true);
1771
-		}
1772
-
1773
-		// si $entite='', on veut la fonction de passage URL ==> id
1774
-		// sinon on veut effectuer le passage id ==> URL
1775
-		if (!$entite) {
1776
-			return $f;
1777
-		}
1778
-
1779
-		// mais d'abord il faut tester le cas des urls sur une
1780
-		// base distante
1781
-		if (is_string($public)
1782
-			and $g = charger_fonction('connect', 'urls', true)
1783
-		) {
1784
-			$f = $g;
1785
-		}
1786
-
1787
-		$res = $f(intval($id), $entite, $args, $ancre, $public);
1788
-
1789
-	}
1790
-	if ($res) {
1791
-		return $res;
1792
-	}
1793
-	// Sinon c'est un raccourci ou compat SPIP < 2
1794
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1795
-		if (!function_exists($f .= '_dist')) {
1796
-			$f = '';
1797
-		}
1798
-	}
1799
-	if ($f) {
1800
-		$url = $f($id, $args, $ancre);
1801
-		if (strlen($args)) {
1802
-			$url .= strstr($url, '?')
1803
-				? '&amp;' . $args
1804
-				: '?' . $args;
1805
-		}
1806
-
1807
-		return $url;
1808
-	}
1809
-	// On a ete gentil mais la ....
1810
-	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1811
-
1812
-	return '';
1745
+    if ($public === null) {
1746
+        $public = !test_espace_prive();
1747
+    }
1748
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1749
+
1750
+    if (!$public) {
1751
+        if (!$entite) {
1752
+            return '';
1753
+        }
1754
+        if (!function_exists('generer_url_ecrire_objet')) {
1755
+            include_spip('inc/urls');
1756
+        }
1757
+        $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1758
+    } else {
1759
+        if ($type === null) {
1760
+            $type = (isset($GLOBALS['type_urls']))
1761
+                ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1762
+                : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1763
+                    ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1764
+        }
1765
+
1766
+        $f = charger_fonction($type, 'urls', true);
1767
+        // se rabattre sur les urls page si les urls perso non dispo
1768
+        if (!$f) {
1769
+            $f = charger_fonction('page', 'urls', true);
1770
+        }
1771
+
1772
+        // si $entite='', on veut la fonction de passage URL ==> id
1773
+        // sinon on veut effectuer le passage id ==> URL
1774
+        if (!$entite) {
1775
+            return $f;
1776
+        }
1777
+
1778
+        // mais d'abord il faut tester le cas des urls sur une
1779
+        // base distante
1780
+        if (is_string($public)
1781
+            and $g = charger_fonction('connect', 'urls', true)
1782
+        ) {
1783
+            $f = $g;
1784
+        }
1785
+
1786
+        $res = $f(intval($id), $entite, $args, $ancre, $public);
1787
+
1788
+    }
1789
+    if ($res) {
1790
+        return $res;
1791
+    }
1792
+    // Sinon c'est un raccourci ou compat SPIP < 2
1793
+    if (!function_exists($f = 'generer_url_' . $entite)) {
1794
+        if (!function_exists($f .= '_dist')) {
1795
+            $f = '';
1796
+        }
1797
+    }
1798
+    if ($f) {
1799
+        $url = $f($id, $args, $ancre);
1800
+        if (strlen($args)) {
1801
+            $url .= strstr($url, '?')
1802
+                ? '&amp;' . $args
1803
+                : '?' . $args;
1804
+        }
1805
+
1806
+        return $url;
1807
+    }
1808
+    // On a ete gentil mais la ....
1809
+    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1810
+
1811
+    return '';
1813 1812
 }
1814 1813
 
1815 1814
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1816
-	$exec = objet_info($entite, 'url_edit');
1817
-	$url = generer_url_ecrire($exec, $args);
1818
-	if (intval($id)) {
1819
-		$url = parametre_url($url, id_table_objet($entite), $id);
1820
-	} else {
1821
-		$url = parametre_url($url, 'new', 'oui');
1822
-	}
1823
-	if ($ancre) {
1824
-		$url = ancre_url($url, $ancre);
1825
-	}
1815
+    $exec = objet_info($entite, 'url_edit');
1816
+    $url = generer_url_ecrire($exec, $args);
1817
+    if (intval($id)) {
1818
+        $url = parametre_url($url, id_table_objet($entite), $id);
1819
+    } else {
1820
+        $url = parametre_url($url, 'new', 'oui');
1821
+    }
1822
+    if ($ancre) {
1823
+        $url = ancre_url($url, $ancre);
1824
+    }
1826 1825
 
1827
-	return $url;
1826
+    return $url;
1828 1827
 }
1829 1828
 
1830 1829
 // https://code.spip.net/@urls_connect_dist
1831 1830
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1832
-	include_spip('base/connect_sql');
1833
-	$id_type = id_table_objet($entite, $public);
1831
+    include_spip('base/connect_sql');
1832
+    $id_type = id_table_objet($entite, $public);
1834 1833
 
1835
-	return _DIR_RACINE . get_spip_script('./')
1836
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1837
-	. (!$args ? '' : "&$args")
1838
-	. (!$ancre ? '' : "#$ancre");
1834
+    return _DIR_RACINE . get_spip_script('./')
1835
+    . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1836
+    . (!$args ? '' : "&$args")
1837
+    . (!$ancre ? '' : "#$ancre");
1839 1838
 }
1840 1839
 
1841 1840
 
@@ -1846,32 +1845,32 @@  discard block
 block discarded – undo
1846 1845
  * @return string
1847 1846
  */
1848 1847
 function urlencode_1738($url) {
1849
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1850
-		$uri = '';
1851
-		for ($i = 0; $i < strlen($url); $i++) {
1852
-			if (ord($a = $url[$i]) > 127) {
1853
-				$a = rawurlencode($a);
1854
-			}
1855
-			$uri .= $a;
1856
-		}
1857
-		$url = $uri;
1858
-	}
1848
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1849
+        $uri = '';
1850
+        for ($i = 0; $i < strlen($url); $i++) {
1851
+            if (ord($a = $url[$i]) > 127) {
1852
+                $a = rawurlencode($a);
1853
+            }
1854
+            $uri .= $a;
1855
+        }
1856
+        $url = $uri;
1857
+    }
1859 1858
 
1860
-	return quote_amp($url);
1859
+    return quote_amp($url);
1861 1860
 }
1862 1861
 
1863 1862
 // https://code.spip.net/@generer_url_entite_absolue
1864 1863
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1865
-	if (!$connect) {
1866
-		$connect = true;
1867
-	}
1868
-	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1869
-	if (!preg_match(',^\w+:,', $h)) {
1870
-		include_spip('inc/filtres_mini');
1871
-		$h = url_absolue($h);
1872
-	}
1864
+    if (!$connect) {
1865
+        $connect = true;
1866
+    }
1867
+    $h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1868
+    if (!preg_match(',^\w+:,', $h)) {
1869
+        include_spip('inc/filtres_mini');
1870
+        $h = url_absolue($h);
1871
+    }
1873 1872
 
1874
-	return $h;
1873
+    return $h;
1875 1874
 }
1876 1875
 
1877 1876
 
@@ -1887,11 +1886,11 @@  discard block
 block discarded – undo
1887 1886
  *     true si la valeur est considérée active ; false sinon.
1888 1887
  **/
1889 1888
 function test_valeur_serveur($truc) {
1890
-	if (!$truc) {
1891
-		return false;
1892
-	}
1889
+    if (!$truc) {
1890
+        return false;
1891
+    }
1893 1892
 
1894
-	return (strtolower($truc) !== 'off');
1893
+    return (strtolower($truc) !== 'off');
1895 1894
 }
1896 1895
 
1897 1896
 //
@@ -1919,80 +1918,80 @@  discard block
 block discarded – undo
1919 1918
  */
1920 1919
 function url_de_base($profondeur = null) {
1921 1920
 
1922
-	static $url = array();
1923
-	if (is_array($profondeur)) {
1924
-		return $url = $profondeur;
1925
-	}
1926
-	if ($profondeur === false) {
1927
-		return $url;
1928
-	}
1929
-
1930
-	if (is_null($profondeur)) {
1931
-		$profondeur = $GLOBALS['profondeur_url'];
1932
-	}
1933
-
1934
-	if (isset($url[$profondeur])) {
1935
-		return $url[$profondeur];
1936
-	}
1937
-
1938
-	$http = 'http';
1939
-
1940
-	if (
1941
-		isset($_SERVER["SCRIPT_URI"])
1942
-		and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1943
-	) {
1944
-		$http = 'https';
1945
-	} elseif (
1946
-		isset($_SERVER['HTTPS'])
1947
-		and test_valeur_serveur($_SERVER['HTTPS'])
1948
-	) {
1949
-		$http = 'https';
1950
-	}
1951
-
1952
-	// note : HTTP_HOST contient le :port si necessaire
1953
-	$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1954
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1955
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1956
-		$host = $GLOBALS['meta']['adresse_site'];
1957
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1958
-			$http = $scheme;
1959
-			$host = str_replace("{$scheme}://", '', $host);
1960
-		}
1961
-	}
1962
-	if (isset($_SERVER['SERVER_PORT'])
1963
-		and $port = $_SERVER['SERVER_PORT']
1964
-		and strpos($host, ":") == false
1965
-	) {
1966
-		if (!defined('_PORT_HTTP_STANDARD')) {
1967
-			define('_PORT_HTTP_STANDARD', '80');
1968
-		}
1969
-		if (!defined('_PORT_HTTPS_STANDARD')) {
1970
-			define('_PORT_HTTPS_STANDARD', '443');
1971
-		}
1972
-		if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
1973
-			$host .= ":$port";
1974
-		}
1975
-		if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
1976
-			$host .= ":$port";
1977
-		}
1978
-	}
1979
-
1980
-	if (!$GLOBALS['REQUEST_URI']) {
1981
-		if (isset($_SERVER['REQUEST_URI'])) {
1982
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
1983
-		} else {
1984
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
1985
-			if (!empty($_SERVER['QUERY_STRING'])
1986
-				and !strpos($_SERVER['REQUEST_URI'], '?')
1987
-			) {
1988
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1989
-			}
1990
-		}
1991
-	}
1992
-
1993
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
1994
-
1995
-	return $url[$profondeur];
1921
+    static $url = array();
1922
+    if (is_array($profondeur)) {
1923
+        return $url = $profondeur;
1924
+    }
1925
+    if ($profondeur === false) {
1926
+        return $url;
1927
+    }
1928
+
1929
+    if (is_null($profondeur)) {
1930
+        $profondeur = $GLOBALS['profondeur_url'];
1931
+    }
1932
+
1933
+    if (isset($url[$profondeur])) {
1934
+        return $url[$profondeur];
1935
+    }
1936
+
1937
+    $http = 'http';
1938
+
1939
+    if (
1940
+        isset($_SERVER["SCRIPT_URI"])
1941
+        and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1942
+    ) {
1943
+        $http = 'https';
1944
+    } elseif (
1945
+        isset($_SERVER['HTTPS'])
1946
+        and test_valeur_serveur($_SERVER['HTTPS'])
1947
+    ) {
1948
+        $http = 'https';
1949
+    }
1950
+
1951
+    // note : HTTP_HOST contient le :port si necessaire
1952
+    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1953
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1954
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1955
+        $host = $GLOBALS['meta']['adresse_site'];
1956
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1957
+            $http = $scheme;
1958
+            $host = str_replace("{$scheme}://", '', $host);
1959
+        }
1960
+    }
1961
+    if (isset($_SERVER['SERVER_PORT'])
1962
+        and $port = $_SERVER['SERVER_PORT']
1963
+        and strpos($host, ":") == false
1964
+    ) {
1965
+        if (!defined('_PORT_HTTP_STANDARD')) {
1966
+            define('_PORT_HTTP_STANDARD', '80');
1967
+        }
1968
+        if (!defined('_PORT_HTTPS_STANDARD')) {
1969
+            define('_PORT_HTTPS_STANDARD', '443');
1970
+        }
1971
+        if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
1972
+            $host .= ":$port";
1973
+        }
1974
+        if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
1975
+            $host .= ":$port";
1976
+        }
1977
+    }
1978
+
1979
+    if (!$GLOBALS['REQUEST_URI']) {
1980
+        if (isset($_SERVER['REQUEST_URI'])) {
1981
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
1982
+        } else {
1983
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
1984
+            if (!empty($_SERVER['QUERY_STRING'])
1985
+                and !strpos($_SERVER['REQUEST_URI'], '?')
1986
+            ) {
1987
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1988
+            }
1989
+        }
1990
+    }
1991
+
1992
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
1993
+
1994
+    return $url[$profondeur];
1996 1995
 }
1997 1996
 
1998 1997
 /**
@@ -2005,26 +2004,26 @@  discard block
 block discarded – undo
2005 2004
  * @return string
2006 2005
  */
2007 2006
 function url_de_($http, $host, $request, $prof = 0) {
2008
-	$prof = max($prof, 0);
2007
+    $prof = max($prof, 0);
2009 2008
 
2010
-	$myself = ltrim($request, '/');
2011
-	# supprimer la chaine de GET
2012
-	list($myself) = explode('?', $myself);
2013
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2014
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2015
-	if (strpos($myself,'://') !== false) {
2016
-		$myself = explode('://',$myself);
2017
-		array_shift($myself);
2018
-		$myself = implode('://',$myself);
2019
-		$myself = explode('/',$myself);
2020
-		array_shift($myself);
2021
-		$myself = implode('/',$myself);
2022
-	}
2023
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2009
+    $myself = ltrim($request, '/');
2010
+    # supprimer la chaine de GET
2011
+    list($myself) = explode('?', $myself);
2012
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2013
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2014
+    if (strpos($myself,'://') !== false) {
2015
+        $myself = explode('://',$myself);
2016
+        array_shift($myself);
2017
+        $myself = implode('://',$myself);
2018
+        $myself = explode('/',$myself);
2019
+        array_shift($myself);
2020
+        $myself = implode('/',$myself);
2021
+    }
2022
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2024 2023
 
2025
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2024
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2026 2025
 
2027
-	return $url;
2026
+    return $url;
2028 2027
 }
2029 2028
 
2030 2029
 
@@ -2059,26 +2058,26 @@  discard block
 block discarded – undo
2059 2058
  * @return string URL
2060 2059
  **/
2061 2060
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2062
-	if (!$rel) {
2063
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2064
-	} else {
2065
-		if (!is_string($rel)) {
2066
-			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2067
-				('./' . _SPIP_ECRIRE_SCRIPT);
2068
-		}
2069
-	}
2070
-
2071
-	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2072
-	if ($script and ($script <> 'accueil' or $rel)) {
2073
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2074
-	} elseif ($args) {
2075
-		$args = "?$args";
2076
-	}
2077
-	if ($ancre) {
2078
-		$args .= "#$ancre";
2079
-	}
2080
-
2081
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2061
+    if (!$rel) {
2062
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2063
+    } else {
2064
+        if (!is_string($rel)) {
2065
+            $rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2066
+                ('./' . _SPIP_ECRIRE_SCRIPT);
2067
+        }
2068
+    }
2069
+
2070
+    list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2071
+    if ($script and ($script <> 'accueil' or $rel)) {
2072
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2073
+    } elseif ($args) {
2074
+        $args = "?$args";
2075
+    }
2076
+    if ($ancre) {
2077
+        $args .= "#$ancre";
2078
+    }
2079
+
2080
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2082 2081
 }
2083 2082
 
2084 2083
 //
@@ -2100,12 +2099,12 @@  discard block
 block discarded – undo
2100 2099
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2101 2100
  **/
2102 2101
 function get_spip_script($default = '') {
2103
-	# cas define('_SPIP_SCRIPT', '');
2104
-	if (_SPIP_SCRIPT) {
2105
-		return _SPIP_SCRIPT;
2106
-	} else {
2107
-		return $default;
2108
-	}
2102
+    # cas define('_SPIP_SCRIPT', '');
2103
+    if (_SPIP_SCRIPT) {
2104
+        return _SPIP_SCRIPT;
2105
+    } else {
2106
+        return $default;
2107
+    }
2109 2108
 }
2110 2109
 
2111 2110
 /**
@@ -2134,39 +2133,39 @@  discard block
 block discarded – undo
2134 2133
  * @return string URL
2135 2134
  **/
2136 2135
 function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') {
2137
-	// si le script est une action (spip_pass, spip_inscription),
2138
-	// standardiser vers la nouvelle API
2139
-
2140
-	if (!$action) {
2141
-		$action = get_spip_script();
2142
-	}
2143
-	if ($script) {
2144
-		$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2145
-	}
2146
-
2147
-	if ($args) {
2148
-		if (is_array($args)) {
2149
-			$r = '';
2150
-			foreach ($args as $k => $v) {
2151
-				$r .= '&' . $k . '=' . $v;
2152
-			}
2153
-			$args = substr($r, 1);
2154
-		}
2155
-		$action .=
2156
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2157
-	}
2158
-	if (!$no_entities) {
2159
-		$action = quote_amp($action);
2160
-	}
2161
-
2162
-	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2163
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2136
+    // si le script est une action (spip_pass, spip_inscription),
2137
+    // standardiser vers la nouvelle API
2138
+
2139
+    if (!$action) {
2140
+        $action = get_spip_script();
2141
+    }
2142
+    if ($script) {
2143
+        $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2144
+    }
2145
+
2146
+    if ($args) {
2147
+        if (is_array($args)) {
2148
+            $r = '';
2149
+            foreach ($args as $k => $v) {
2150
+                $r .= '&' . $k . '=' . $v;
2151
+            }
2152
+            $args = substr($r, 1);
2153
+        }
2154
+        $action .=
2155
+            (strpos($action, '?') !== false ? '&' : '?') . $args;
2156
+    }
2157
+    if (!$no_entities) {
2158
+        $action = quote_amp($action);
2159
+    }
2160
+
2161
+    // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2162
+    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2164 2163
 }
2165 2164
 
2166 2165
 // https://code.spip.net/@generer_url_prive
2167 2166
 function generer_url_prive($script, $args = "", $no_entities = false) {
2168 2167
 
2169
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2168
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2170 2169
 }
2171 2170
 
2172 2171
 // Pour les formulaires en methode POST,
@@ -2191,19 +2190,19 @@  discard block
 block discarded – undo
2191 2190
  **/
2192 2191
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2193 2192
 
2194
-	$script1 = explode('&', $script);
2195
-	$script1 = reset($script1);
2193
+    $script1 = explode('&', $script);
2194
+    $script1 = reset($script1);
2196 2195
 
2197
-	return "<form action='"
2198
-	. ($script ? generer_url_ecrire($script) : '')
2199
-	. "' "
2200
-	. ($atts ? $atts : " method='post'")
2201
-	. "><div>\n"
2202
-	. "<input type='hidden' name='exec' value='$script1' />"
2203
-	. $corps
2204
-	. (!$submit ? '' :
2205
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2206
-	. "</div></form>\n";
2196
+    return "<form action='"
2197
+    . ($script ? generer_url_ecrire($script) : '')
2198
+    . "' "
2199
+    . ($atts ? $atts : " method='post'")
2200
+    . "><div>\n"
2201
+    . "<input type='hidden' name='exec' value='$script1' />"
2202
+    . $corps
2203
+    . (!$submit ? '' :
2204
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2205
+    . "</div></form>\n";
2207 2206
 }
2208 2207
 
2209 2208
 /**
@@ -2220,22 +2219,22 @@  discard block
 block discarded – undo
2220 2219
  * @return string
2221 2220
  */
2222 2221
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2223
-	// si l'on est dans l'espace prive, on garde dans l'url
2224
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2225
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2226
-	$h = (_DIR_RACINE and !$public)
2227
-		? generer_url_ecrire(_request('exec'))
2228
-		: generer_url_public();
2222
+    // si l'on est dans l'espace prive, on garde dans l'url
2223
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2224
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2225
+    $h = (_DIR_RACINE and !$public)
2226
+        ? generer_url_ecrire(_request('exec'))
2227
+        : generer_url_public();
2229 2228
 
2230
-	return "\n<form action='" .
2231
-	$h .
2232
-	"'" .
2233
-	$atts .
2234
-	">\n" .
2235
-	"<div>" .
2236
-	"\n<input type='hidden' name='action' value='$script' />" .
2237
-	$corps .
2238
-	"</div></form>";
2229
+    return "\n<form action='" .
2230
+    $h .
2231
+    "'" .
2232
+    $atts .
2233
+    ">\n" .
2234
+    "<div>" .
2235
+    "\n<input type='hidden' name='action' value='$script' />" .
2236
+    $corps .
2237
+    "</div></form>";
2239 2238
 }
2240 2239
 
2241 2240
 /**
@@ -2254,22 +2253,22 @@  discard block
 block discarded – undo
2254 2253
  *     URL
2255 2254
  */
2256 2255
 function generer_url_action($script, $args = "", $no_entities = false, $public = false) {
2257
-	// si l'on est dans l'espace prive, on garde dans l'url
2258
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2259
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2260
-	$url = (_DIR_RACINE and !$public)
2261
-		? generer_url_ecrire(_request('exec'))
2262
-		: generer_url_public('', '', false, false);
2263
-	$url = parametre_url($url, 'action', $script);
2264
-	if ($args) {
2265
-		$url .= quote_amp('&' . $args);
2266
-	}
2256
+    // si l'on est dans l'espace prive, on garde dans l'url
2257
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2258
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2259
+    $url = (_DIR_RACINE and !$public)
2260
+        ? generer_url_ecrire(_request('exec'))
2261
+        : generer_url_public('', '', false, false);
2262
+    $url = parametre_url($url, 'action', $script);
2263
+    if ($args) {
2264
+        $url .= quote_amp('&' . $args);
2265
+    }
2267 2266
 
2268
-	if ($no_entities) {
2269
-		$url = str_replace('&amp;', '&', $url);
2270
-	}
2267
+    if ($no_entities) {
2268
+        $url = str_replace('&amp;', '&', $url);
2269
+    }
2271 2270
 
2272
-	return $url;
2271
+    return $url;
2273 2272
 }
2274 2273
 
2275 2274
 
@@ -2282,8 +2281,8 @@  discard block
 block discarded – undo
2282 2281
  * @param string $ta Répertoire temporaire accessible
2283 2282
  */
2284 2283
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2285
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2286
-	spip_initialisation_suite();
2284
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2285
+    spip_initialisation_suite();
2287 2286
 }
2288 2287
 
2289 2288
 /**
@@ -2303,315 +2302,315 @@  discard block
 block discarded – undo
2303 2302
  * @param string $ta Répertoire temporaire accessible
2304 2303
  */
2305 2304
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2306
-	static $too_late = 0;
2307
-	if ($too_late++) {
2308
-		return;
2309
-	}
2310
-
2311
-	// Declaration des repertoires
2312
-
2313
-	// le nom du repertoire plugins/ activables/desactivables
2314
-	if (!defined('_DIR_PLUGINS')) {
2315
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2316
-	}
2317
-
2318
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2319
-	if (!defined('_DIR_PLUGINS_DIST')) {
2320
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2321
-	}
2322
-
2323
-	// le nom du repertoire des librairies
2324
-	if (!defined('_DIR_LIB')) {
2325
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2326
-	}
2327
-
2328
-	if (!defined('_DIR_IMG')) {
2329
-		define('_DIR_IMG', $pa);
2330
-	}
2331
-	if (!defined('_DIR_LOGOS')) {
2332
-		define('_DIR_LOGOS', $pa);
2333
-	}
2334
-	if (!defined('_DIR_IMG_ICONES')) {
2335
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2336
-	}
2337
-
2338
-	if (!defined('_DIR_DUMP')) {
2339
-		define('_DIR_DUMP', $ti . "dump/");
2340
-	}
2341
-	if (!defined('_DIR_SESSIONS')) {
2342
-		define('_DIR_SESSIONS', $ti . "sessions/");
2343
-	}
2344
-	if (!defined('_DIR_TRANSFERT')) {
2345
-		define('_DIR_TRANSFERT', $ti . "upload/");
2346
-	}
2347
-	if (!defined('_DIR_CACHE')) {
2348
-		define('_DIR_CACHE', $ti . "cache/");
2349
-	}
2350
-	if (!defined('_DIR_CACHE_XML')) {
2351
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2352
-	}
2353
-	if (!defined('_DIR_SKELS')) {
2354
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2355
-	}
2356
-	if (!defined('_DIR_AIDE')) {
2357
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2358
-	}
2359
-	if (!defined('_DIR_TMP')) {
2360
-		define('_DIR_TMP', $ti);
2361
-	}
2362
-
2363
-	if (!defined('_DIR_VAR')) {
2364
-		define('_DIR_VAR', $ta);
2365
-	}
2366
-
2367
-	if (!defined('_DIR_ETC')) {
2368
-		define('_DIR_ETC', $pi);
2369
-	}
2370
-	if (!defined('_DIR_CONNECT')) {
2371
-		define('_DIR_CONNECT', $pi);
2372
-	}
2373
-	if (!defined('_DIR_CHMOD')) {
2374
-		define('_DIR_CHMOD', $pi);
2375
-	}
2376
-
2377
-	if (!isset($GLOBALS['test_dirs']))
2378
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2379
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2380
-	{
2381
-		$GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2382
-	}
2383
-
2384
-	// Declaration des fichiers
2385
-
2386
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2387
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2388
-	}
2389
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2390
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2391
-	}
2392
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2393
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2394
-	}
2395
-	if (!defined('_CACHE_PIPELINES')) {
2396
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2397
-	}
2398
-	if (!defined('_CACHE_CHEMIN')) {
2399
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2400
-	}
2401
-
2402
-	# attention .php obligatoire pour ecrire_fichier_securise
2403
-	if (!defined('_FILE_META')) {
2404
-		define('_FILE_META', $ti . 'meta_cache.php');
2405
-	}
2406
-	if (!defined('_DIR_LOG')) {
2407
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2408
-	}
2409
-	if (!defined('_FILE_LOG')) {
2410
-		define('_FILE_LOG', 'spip');
2411
-	}
2412
-	if (!defined('_FILE_LOG_SUFFIX')) {
2413
-		define('_FILE_LOG_SUFFIX', '.log');
2414
-	}
2415
-
2416
-	// Le fichier de connexion a la base de donnees
2417
-	// tient compte des anciennes versions (inc_connect...)
2418
-	if (!defined('_FILE_CONNECT_INS')) {
2419
-		define('_FILE_CONNECT_INS', 'connect');
2420
-	}
2421
-	if (!defined('_FILE_CONNECT')) {
2422
-		define('_FILE_CONNECT',
2423
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2424
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2425
-				: false)));
2426
-	}
2427
-
2428
-	// Le fichier de reglages des droits
2429
-	if (!defined('_FILE_CHMOD_INS')) {
2430
-		define('_FILE_CHMOD_INS', 'chmod');
2431
-	}
2432
-	if (!defined('_FILE_CHMOD')) {
2433
-		define('_FILE_CHMOD',
2434
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2435
-			: false));
2436
-	}
2437
-
2438
-	if (!defined('_FILE_LDAP')) {
2439
-		define('_FILE_LDAP', 'ldap.php');
2440
-	}
2441
-
2442
-	if (!defined('_FILE_TMP_SUFFIX')) {
2443
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2444
-	}
2445
-	if (!defined('_FILE_CONNECT_TMP')) {
2446
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2447
-	}
2448
-	if (!defined('_FILE_CHMOD_TMP')) {
2449
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2450
-	}
2451
-
2452
-	// Definition des droits d'acces en ecriture
2453
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2454
-		include_once _FILE_CHMOD;
2455
-	}
2456
-
2457
-	// Se mefier des fichiers mal remplis!
2458
-	if (!defined('_SPIP_CHMOD')) {
2459
-		define('_SPIP_CHMOD', 0777);
2460
-	}
2461
-
2462
-	if (!defined('_DEFAULT_CHARSET')) {
2463
-		/** Le charset par défaut lors de l'installation */
2464
-		define('_DEFAULT_CHARSET', 'utf-8');
2465
-	}
2466
-	if (!defined('_ROOT_PLUGINS')) {
2467
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2468
-	}
2469
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2470
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2471
-	}
2472
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2473
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2474
-	}
2475
-
2476
-	// La taille des Log
2477
-	if (!defined('_MAX_LOG')) {
2478
-		define('_MAX_LOG', 100);
2479
-	}
2480
-
2481
-	// Sommes-nous dans l'empire du Mal ?
2482
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2483
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2484
-		if (!defined('_OS_SERVEUR')) {
2485
-			define('_OS_SERVEUR', 'windows');
2486
-		}
2487
-		if (!defined('_SPIP_LOCK_MODE')) {
2488
-			define('_SPIP_LOCK_MODE', 1);
2489
-		} // utiliser le flock php
2490
-	} else {
2491
-		if (!defined('_OS_SERVEUR')) {
2492
-			define('_OS_SERVEUR', '');
2493
-		}
2494
-		if (!defined('_SPIP_LOCK_MODE')) {
2495
-			define('_SPIP_LOCK_MODE', 1);
2496
-		} // utiliser le flock php
2497
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2498
-	}
2499
-
2500
-	// Langue par defaut
2501
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2502
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2503
-	}
2504
-
2505
-	//
2506
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2507
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2508
-	// pour le rendre surchargeable, on va provoquer un reecriture
2509
-	// systematique du noyau ou une baisse de perfs => a etudier)
2510
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2511
-
2512
-	// charger tout de suite le path et son cache
2513
-	load_path_cache();
2514
-
2515
-	// *********** traiter les variables ************
2516
-
2517
-	//
2518
-	// Securite
2519
-	//
2520
-
2521
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2522
-	if (isset($_REQUEST['GLOBALS'])) {
2523
-		die();
2524
-	}
2525
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2526
-	spip_desinfecte($_GET);
2527
-	spip_desinfecte($_POST);
2528
-	spip_desinfecte($_COOKIE);
2529
-	spip_desinfecte($_REQUEST);
2530
-
2531
-	// appliquer le cookie_prefix
2532
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2533
-		include_spip('inc/cookie');
2534
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2535
-	}
2536
-
2537
-	//
2538
-	// Capacites php (en fonction de la version)
2539
-	//
2540
-	$GLOBALS['flag_ob'] = (function_exists("ob_start")
2541
-		&& function_exists("ini_get")
2542
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2543
-	$GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2544
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2545
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2546
-		(get_cfg_var('upload_max_filesize') > 0));
2547
-
2548
-
2549
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2550
-	if (isset($_SERVER['REQUEST_URI'])) {
2551
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2552
-	} else {
2553
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2554
-		if (!empty($_SERVER['QUERY_STRING'])
2555
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2556
-		) {
2557
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2558
-		}
2559
-	}
2560
-
2561
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2562
-	if (!defined('_RENOUVELLE_ALEA')) {
2563
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2564
-	}
2565
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2566
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2567
-	}
2568
-
2569
-	// charger les meta si possible et renouveller l'alea au besoin
2570
-	// charge aussi effacer_meta et ecrire_meta
2571
-	$inc_meta = charger_fonction('meta', 'inc');
2572
-	$inc_meta();
2573
-
2574
-	// nombre de repertoires depuis la racine
2575
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2576
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2577
-	// le calcul est faux)
2578
-	if (!_DIR_RESTREINT) {
2579
-		$GLOBALS['profondeur_url'] = 1;
2580
-	} else {
2581
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2582
-		$uri_ref = $_SERVER["SCRIPT_NAME"];
2583
-		if (!$uri_ref
2584
-			// si on est appele avec un autre ti, on est sans doute en mutu
2585
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2586
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2587
-			// s'en remettre a l'adresse du site. alea jacta est.
2588
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2589
-		) {
2590
-
2591
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2592
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2593
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2594
-			} else {
2595
-				$uri_ref = "";
2596
-			}
2597
-		}
2598
-		if (!$uri or !$uri_ref) {
2599
-			$GLOBALS['profondeur_url'] = 0;
2600
-		} else {
2601
-			$GLOBALS['profondeur_url'] = max(0,
2602
-				substr_count($uri[0], '/')
2603
-				- substr_count($uri_ref, '/'));
2604
-		}
2605
-	}
2606
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2607
-	if (_FILE_CONNECT) {
2608
-		if (verifier_visiteur() == '0minirezo'
2609
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2610
-			and !isset($_COOKIE['spip_admin'])
2611
-		) {
2612
-			clear_path_cache();
2613
-		}
2614
-	}
2305
+    static $too_late = 0;
2306
+    if ($too_late++) {
2307
+        return;
2308
+    }
2309
+
2310
+    // Declaration des repertoires
2311
+
2312
+    // le nom du repertoire plugins/ activables/desactivables
2313
+    if (!defined('_DIR_PLUGINS')) {
2314
+        define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2315
+    }
2316
+
2317
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2318
+    if (!defined('_DIR_PLUGINS_DIST')) {
2319
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2320
+    }
2321
+
2322
+    // le nom du repertoire des librairies
2323
+    if (!defined('_DIR_LIB')) {
2324
+        define('_DIR_LIB', _DIR_RACINE . "lib/");
2325
+    }
2326
+
2327
+    if (!defined('_DIR_IMG')) {
2328
+        define('_DIR_IMG', $pa);
2329
+    }
2330
+    if (!defined('_DIR_LOGOS')) {
2331
+        define('_DIR_LOGOS', $pa);
2332
+    }
2333
+    if (!defined('_DIR_IMG_ICONES')) {
2334
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2335
+    }
2336
+
2337
+    if (!defined('_DIR_DUMP')) {
2338
+        define('_DIR_DUMP', $ti . "dump/");
2339
+    }
2340
+    if (!defined('_DIR_SESSIONS')) {
2341
+        define('_DIR_SESSIONS', $ti . "sessions/");
2342
+    }
2343
+    if (!defined('_DIR_TRANSFERT')) {
2344
+        define('_DIR_TRANSFERT', $ti . "upload/");
2345
+    }
2346
+    if (!defined('_DIR_CACHE')) {
2347
+        define('_DIR_CACHE', $ti . "cache/");
2348
+    }
2349
+    if (!defined('_DIR_CACHE_XML')) {
2350
+        define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2351
+    }
2352
+    if (!defined('_DIR_SKELS')) {
2353
+        define('_DIR_SKELS', _DIR_CACHE . "skel/");
2354
+    }
2355
+    if (!defined('_DIR_AIDE')) {
2356
+        define('_DIR_AIDE', _DIR_CACHE . "aide/");
2357
+    }
2358
+    if (!defined('_DIR_TMP')) {
2359
+        define('_DIR_TMP', $ti);
2360
+    }
2361
+
2362
+    if (!defined('_DIR_VAR')) {
2363
+        define('_DIR_VAR', $ta);
2364
+    }
2365
+
2366
+    if (!defined('_DIR_ETC')) {
2367
+        define('_DIR_ETC', $pi);
2368
+    }
2369
+    if (!defined('_DIR_CONNECT')) {
2370
+        define('_DIR_CONNECT', $pi);
2371
+    }
2372
+    if (!defined('_DIR_CHMOD')) {
2373
+        define('_DIR_CHMOD', $pi);
2374
+    }
2375
+
2376
+    if (!isset($GLOBALS['test_dirs']))
2377
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2378
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2379
+    {
2380
+        $GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2381
+    }
2382
+
2383
+    // Declaration des fichiers
2384
+
2385
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2386
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2387
+    }
2388
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2389
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2390
+    }
2391
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2392
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2393
+    }
2394
+    if (!defined('_CACHE_PIPELINES')) {
2395
+        define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2396
+    }
2397
+    if (!defined('_CACHE_CHEMIN')) {
2398
+        define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2399
+    }
2400
+
2401
+    # attention .php obligatoire pour ecrire_fichier_securise
2402
+    if (!defined('_FILE_META')) {
2403
+        define('_FILE_META', $ti . 'meta_cache.php');
2404
+    }
2405
+    if (!defined('_DIR_LOG')) {
2406
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2407
+    }
2408
+    if (!defined('_FILE_LOG')) {
2409
+        define('_FILE_LOG', 'spip');
2410
+    }
2411
+    if (!defined('_FILE_LOG_SUFFIX')) {
2412
+        define('_FILE_LOG_SUFFIX', '.log');
2413
+    }
2414
+
2415
+    // Le fichier de connexion a la base de donnees
2416
+    // tient compte des anciennes versions (inc_connect...)
2417
+    if (!defined('_FILE_CONNECT_INS')) {
2418
+        define('_FILE_CONNECT_INS', 'connect');
2419
+    }
2420
+    if (!defined('_FILE_CONNECT')) {
2421
+        define('_FILE_CONNECT',
2422
+        (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2423
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2424
+                : false)));
2425
+    }
2426
+
2427
+    // Le fichier de reglages des droits
2428
+    if (!defined('_FILE_CHMOD_INS')) {
2429
+        define('_FILE_CHMOD_INS', 'chmod');
2430
+    }
2431
+    if (!defined('_FILE_CHMOD')) {
2432
+        define('_FILE_CHMOD',
2433
+        (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2434
+            : false));
2435
+    }
2436
+
2437
+    if (!defined('_FILE_LDAP')) {
2438
+        define('_FILE_LDAP', 'ldap.php');
2439
+    }
2440
+
2441
+    if (!defined('_FILE_TMP_SUFFIX')) {
2442
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2443
+    }
2444
+    if (!defined('_FILE_CONNECT_TMP')) {
2445
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2446
+    }
2447
+    if (!defined('_FILE_CHMOD_TMP')) {
2448
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2449
+    }
2450
+
2451
+    // Definition des droits d'acces en ecriture
2452
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2453
+        include_once _FILE_CHMOD;
2454
+    }
2455
+
2456
+    // Se mefier des fichiers mal remplis!
2457
+    if (!defined('_SPIP_CHMOD')) {
2458
+        define('_SPIP_CHMOD', 0777);
2459
+    }
2460
+
2461
+    if (!defined('_DEFAULT_CHARSET')) {
2462
+        /** Le charset par défaut lors de l'installation */
2463
+        define('_DEFAULT_CHARSET', 'utf-8');
2464
+    }
2465
+    if (!defined('_ROOT_PLUGINS')) {
2466
+        define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2467
+    }
2468
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2469
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2470
+    }
2471
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2472
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2473
+    }
2474
+
2475
+    // La taille des Log
2476
+    if (!defined('_MAX_LOG')) {
2477
+        define('_MAX_LOG', 100);
2478
+    }
2479
+
2480
+    // Sommes-nous dans l'empire du Mal ?
2481
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2482
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2483
+        if (!defined('_OS_SERVEUR')) {
2484
+            define('_OS_SERVEUR', 'windows');
2485
+        }
2486
+        if (!defined('_SPIP_LOCK_MODE')) {
2487
+            define('_SPIP_LOCK_MODE', 1);
2488
+        } // utiliser le flock php
2489
+    } else {
2490
+        if (!defined('_OS_SERVEUR')) {
2491
+            define('_OS_SERVEUR', '');
2492
+        }
2493
+        if (!defined('_SPIP_LOCK_MODE')) {
2494
+            define('_SPIP_LOCK_MODE', 1);
2495
+        } // utiliser le flock php
2496
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2497
+    }
2498
+
2499
+    // Langue par defaut
2500
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2501
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2502
+    }
2503
+
2504
+    //
2505
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2506
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2507
+    // pour le rendre surchargeable, on va provoquer un reecriture
2508
+    // systematique du noyau ou une baisse de perfs => a etudier)
2509
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2510
+
2511
+    // charger tout de suite le path et son cache
2512
+    load_path_cache();
2513
+
2514
+    // *********** traiter les variables ************
2515
+
2516
+    //
2517
+    // Securite
2518
+    //
2519
+
2520
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2521
+    if (isset($_REQUEST['GLOBALS'])) {
2522
+        die();
2523
+    }
2524
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2525
+    spip_desinfecte($_GET);
2526
+    spip_desinfecte($_POST);
2527
+    spip_desinfecte($_COOKIE);
2528
+    spip_desinfecte($_REQUEST);
2529
+
2530
+    // appliquer le cookie_prefix
2531
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2532
+        include_spip('inc/cookie');
2533
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2534
+    }
2535
+
2536
+    //
2537
+    // Capacites php (en fonction de la version)
2538
+    //
2539
+    $GLOBALS['flag_ob'] = (function_exists("ob_start")
2540
+        && function_exists("ini_get")
2541
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2542
+    $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2543
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2544
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2545
+        (get_cfg_var('upload_max_filesize') > 0));
2546
+
2547
+
2548
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2549
+    if (isset($_SERVER['REQUEST_URI'])) {
2550
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2551
+    } else {
2552
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2553
+        if (!empty($_SERVER['QUERY_STRING'])
2554
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2555
+        ) {
2556
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2557
+        }
2558
+    }
2559
+
2560
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2561
+    if (!defined('_RENOUVELLE_ALEA')) {
2562
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2563
+    }
2564
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2565
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2566
+    }
2567
+
2568
+    // charger les meta si possible et renouveller l'alea au besoin
2569
+    // charge aussi effacer_meta et ecrire_meta
2570
+    $inc_meta = charger_fonction('meta', 'inc');
2571
+    $inc_meta();
2572
+
2573
+    // nombre de repertoires depuis la racine
2574
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2575
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2576
+    // le calcul est faux)
2577
+    if (!_DIR_RESTREINT) {
2578
+        $GLOBALS['profondeur_url'] = 1;
2579
+    } else {
2580
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2581
+        $uri_ref = $_SERVER["SCRIPT_NAME"];
2582
+        if (!$uri_ref
2583
+            // si on est appele avec un autre ti, on est sans doute en mutu
2584
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2585
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2586
+            // s'en remettre a l'adresse du site. alea jacta est.
2587
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2588
+        ) {
2589
+
2590
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2591
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2592
+                $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2593
+            } else {
2594
+                $uri_ref = "";
2595
+            }
2596
+        }
2597
+        if (!$uri or !$uri_ref) {
2598
+            $GLOBALS['profondeur_url'] = 0;
2599
+        } else {
2600
+            $GLOBALS['profondeur_url'] = max(0,
2601
+                substr_count($uri[0], '/')
2602
+                - substr_count($uri_ref, '/'));
2603
+        }
2604
+    }
2605
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2606
+    if (_FILE_CONNECT) {
2607
+        if (verifier_visiteur() == '0minirezo'
2608
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2609
+            and !isset($_COOKIE['spip_admin'])
2610
+        ) {
2611
+            clear_path_cache();
2612
+        }
2613
+    }
2615 2614
 
2616 2615
 }
2617 2616
 
@@ -2621,174 +2620,174 @@  discard block
 block discarded – undo
2621 2620
  *
2622 2621
  */
2623 2622
 function spip_initialisation_suite() {
2624
-	static $too_late = 0;
2625
-	if ($too_late++) {
2626
-		return;
2627
-	}
2628
-
2629
-	// taille mini des login
2630
-	if (!defined('_LOGIN_TROP_COURT')) {
2631
-		define('_LOGIN_TROP_COURT', 4);
2632
-	}
2633
-
2634
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2635
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2636
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2637
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2638
-
2639
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2640
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2641
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2642
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2643
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2644
-
2645
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2646
-		define('_PASS_LONGUEUR_MINI', 6);
2647
-	}
2648
-
2649
-
2650
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2651
-	if (!defined('_IMG_QUALITE')) {
2652
-		define('_IMG_QUALITE', 85);
2653
-	} # valeur par defaut
2654
-	if (!defined('_IMG_GD_QUALITE')) {
2655
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2656
-	} # surcharge pour la lib GD
2657
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2658
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2659
-	} # surcharge pour imagick en ligne de commande
2660
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2661
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2662
-		define('_IMG_IMAGICK_QUALITE', 75);
2663
-	} # surcharge pour imagick en PHP
2664
-
2665
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2666
-		define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2667
-	} // poids en octet
2668
-
2669
-	// qq chaines standard
2670
-	if (!defined('_ACCESS_FILE_NAME')) {
2671
-		define('_ACCESS_FILE_NAME', '.htaccess');
2672
-	}
2673
-	if (!defined('_AUTH_USER_FILE')) {
2674
-		define('_AUTH_USER_FILE', '.htpasswd');
2675
-	}
2676
-	if (!defined('_SPIP_DUMP')) {
2677
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2678
-	}
2679
-	if (!defined('_CACHE_RUBRIQUES')) {
2680
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2681
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2682
-	}
2683
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2684
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2685
-		define('_CACHE_RUBRIQUES_MAX', 500);
2686
-	}
2687
-
2688
-	if (!defined('_EXTENSION_SQUELETTES')) {
2689
-		define('_EXTENSION_SQUELETTES', 'html');
2690
-	}
2691
-
2692
-	if (!defined('_DOCTYPE_ECRIRE')) {
2693
-		/** Définit le doctype de l’espace privé */
2694
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2695
-	}
2696
-	if (!defined('_DOCTYPE_AIDE')) {
2697
-		/** Définit le doctype de l’aide en ligne */
2698
-		define('_DOCTYPE_AIDE',
2699
-		"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2700
-	}
2701
-
2702
-	if (!defined('_SPIP_SCRIPT')) {
2703
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2704
-		 * le script de l'espace public, alias index.php */
2705
-		define('_SPIP_SCRIPT', 'spip.php');
2706
-	}
2707
-	if (!defined('_SPIP_PAGE')) {
2708
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2709
-		define('_SPIP_PAGE', 'page');
2710
-	}
2711
-
2712
-	// le script de l'espace prive
2713
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2714
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2715
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2716
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2717
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2718
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2719
-		} else {
2720
-			define('_SPIP_ECRIRE_SCRIPT', '');
2721
-		}
2722
-	}
2723
-
2724
-
2725
-	if (!defined('_SPIP_AJAX')) {
2726
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2727
-			? 1
2728
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2729
-	}
2730
-
2731
-	// La requete est-elle en ajax ?
2732
-	if (!defined('_AJAX')) {
2733
-		define('_AJAX',
2734
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2735
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2736
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2737
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2738
-			)
2739
-			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
2740
-		);
2741
-	}
2742
-
2743
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2744
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2745
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2746
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2747
-		define('_IMG_GD_MAX_PIXELS',
2748
-		(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2749
-			? $GLOBALS['meta']['max_taille_vignettes']
2750
-			: 0);
2751
-	}
2752
-
2753
-	if (!defined('_MEMORY_LIMIT_MIN')) {
2754
-		define('_MEMORY_LIMIT_MIN', 16);
2755
-	} // en Mo
2756
-	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2757
-	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2758
-	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2759
-	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2760
-		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2761
-			$unit = strtolower(substr($memory, -1));
2762
-			$memory = substr($memory, 0, -1);
2763
-			switch ($unit) {
2764
-				// Le modifieur 'G' est disponible depuis PHP 5.1.0
2765
-				case 'g':
2766
-					$memory *= 1024;
2767
-				case 'm':
2768
-					$memory *= 1024;
2769
-				case 'k':
2770
-					$memory *= 1024;
2771
-			}
2772
-			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2773
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2774
-				if (trim(ini_get('memory_limit')) != $m) {
2775
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2776
-						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2777
-					} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2778
-				}
2779
-			}
2780
-		} else {
2781
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2782
-				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2783
-			}
2784
-		} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2785
-	}
2786
-	// Protocoles a normaliser dans les chaines de langues
2787
-	if (!defined('_PROTOCOLES_STD')) {
2788
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2789
-	}
2790
-
2791
-	init_var_mode();
2623
+    static $too_late = 0;
2624
+    if ($too_late++) {
2625
+        return;
2626
+    }
2627
+
2628
+    // taille mini des login
2629
+    if (!defined('_LOGIN_TROP_COURT')) {
2630
+        define('_LOGIN_TROP_COURT', 4);
2631
+    }
2632
+
2633
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2634
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2635
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2636
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2637
+
2638
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2639
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2640
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2641
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2642
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2643
+
2644
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2645
+        define('_PASS_LONGUEUR_MINI', 6);
2646
+    }
2647
+
2648
+
2649
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2650
+    if (!defined('_IMG_QUALITE')) {
2651
+        define('_IMG_QUALITE', 85);
2652
+    } # valeur par defaut
2653
+    if (!defined('_IMG_GD_QUALITE')) {
2654
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2655
+    } # surcharge pour la lib GD
2656
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2657
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2658
+    } # surcharge pour imagick en ligne de commande
2659
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2660
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2661
+        define('_IMG_IMAGICK_QUALITE', 75);
2662
+    } # surcharge pour imagick en PHP
2663
+
2664
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2665
+        define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2666
+    } // poids en octet
2667
+
2668
+    // qq chaines standard
2669
+    if (!defined('_ACCESS_FILE_NAME')) {
2670
+        define('_ACCESS_FILE_NAME', '.htaccess');
2671
+    }
2672
+    if (!defined('_AUTH_USER_FILE')) {
2673
+        define('_AUTH_USER_FILE', '.htpasswd');
2674
+    }
2675
+    if (!defined('_SPIP_DUMP')) {
2676
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2677
+    }
2678
+    if (!defined('_CACHE_RUBRIQUES')) {
2679
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2680
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2681
+    }
2682
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2683
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2684
+        define('_CACHE_RUBRIQUES_MAX', 500);
2685
+    }
2686
+
2687
+    if (!defined('_EXTENSION_SQUELETTES')) {
2688
+        define('_EXTENSION_SQUELETTES', 'html');
2689
+    }
2690
+
2691
+    if (!defined('_DOCTYPE_ECRIRE')) {
2692
+        /** Définit le doctype de l’espace privé */
2693
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2694
+    }
2695
+    if (!defined('_DOCTYPE_AIDE')) {
2696
+        /** Définit le doctype de l’aide en ligne */
2697
+        define('_DOCTYPE_AIDE',
2698
+        "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2699
+    }
2700
+
2701
+    if (!defined('_SPIP_SCRIPT')) {
2702
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2703
+         * le script de l'espace public, alias index.php */
2704
+        define('_SPIP_SCRIPT', 'spip.php');
2705
+    }
2706
+    if (!defined('_SPIP_PAGE')) {
2707
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2708
+        define('_SPIP_PAGE', 'page');
2709
+    }
2710
+
2711
+    // le script de l'espace prive
2712
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2713
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2714
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2715
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2716
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2717
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2718
+        } else {
2719
+            define('_SPIP_ECRIRE_SCRIPT', '');
2720
+        }
2721
+    }
2722
+
2723
+
2724
+    if (!defined('_SPIP_AJAX')) {
2725
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2726
+            ? 1
2727
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2728
+    }
2729
+
2730
+    // La requete est-elle en ajax ?
2731
+    if (!defined('_AJAX')) {
2732
+        define('_AJAX',
2733
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2734
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2735
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2736
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2737
+            )
2738
+            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
2739
+        );
2740
+    }
2741
+
2742
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2743
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2744
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2745
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2746
+        define('_IMG_GD_MAX_PIXELS',
2747
+        (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2748
+            ? $GLOBALS['meta']['max_taille_vignettes']
2749
+            : 0);
2750
+    }
2751
+
2752
+    if (!defined('_MEMORY_LIMIT_MIN')) {
2753
+        define('_MEMORY_LIMIT_MIN', 16);
2754
+    } // en Mo
2755
+    // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2756
+    // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2757
+    // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2758
+    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2759
+        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2760
+            $unit = strtolower(substr($memory, -1));
2761
+            $memory = substr($memory, 0, -1);
2762
+            switch ($unit) {
2763
+                // Le modifieur 'G' est disponible depuis PHP 5.1.0
2764
+                case 'g':
2765
+                    $memory *= 1024;
2766
+                case 'm':
2767
+                    $memory *= 1024;
2768
+                case 'k':
2769
+                    $memory *= 1024;
2770
+            }
2771
+            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2772
+                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2773
+                if (trim(ini_get('memory_limit')) != $m) {
2774
+                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2775
+                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2776
+                    } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2777
+                }
2778
+            }
2779
+        } else {
2780
+            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2781
+                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2782
+            }
2783
+        } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2784
+    }
2785
+    // Protocoles a normaliser dans les chaines de langues
2786
+    if (!defined('_PROTOCOLES_STD')) {
2787
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2788
+    }
2789
+
2790
+    init_var_mode();
2792 2791
 }
2793 2792
 
2794 2793
 /**
@@ -2822,129 +2821,129 @@  discard block
 block discarded – undo
2822 2821
  * `   var_mode` (calcul ou recalcul).
2823 2822
  */
2824 2823
 function init_var_mode() {
2825
-	static $done = false;
2826
-	if (!$done) {
2827
-
2828
-		if (isset($_GET['var_mode'])) {
2829
-			$var_mode = explode(',', $_GET['var_mode']);
2830
-			// tout le monde peut calcul/recalcul
2831
-			if (!defined('_VAR_MODE')) {
2832
-				if (in_array('recalcul', $var_mode)) {
2833
-					define('_VAR_MODE', 'recalcul');
2834
-				} elseif (in_array('calcul', $var_mode)) {
2835
-					define('_VAR_MODE', 'calcul');
2836
-				}
2837
-			}
2838
-			$var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2839
-			if ($var_mode) {
2840
-				include_spip('inc/autoriser');
2841
-				// autoriser preview si preview seulement, et sinon autoriser debug
2842
-				if (autoriser(
2843
-					($_GET['var_mode'] == 'preview')
2844
-						? 'previsualiser'
2845
-						: 'debug'
2846
-				)) {
2847
-					if (in_array('traduction', $var_mode)) {
2848
-						// forcer le calcul pour passer dans traduire
2849
-						if (!defined('_VAR_MODE')) {
2850
-							define('_VAR_MODE', 'calcul');
2851
-						}
2852
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2853
-						if (!defined('_VAR_NOCACHE')) {
2854
-							define('_VAR_NOCACHE', true);
2855
-						}
2856
-						$var_mode = array_diff($var_mode, array('traduction'));
2857
-					}
2858
-					if (in_array('preview', $var_mode)) {
2859
-						// basculer sur les criteres de preview dans les boucles
2860
-						if (!defined('_VAR_PREVIEW')) {
2861
-							define('_VAR_PREVIEW', true);
2862
-						}
2863
-						// forcer le calcul
2864
-						if (!defined('_VAR_MODE')) {
2865
-							define('_VAR_MODE', 'calcul');
2866
-						}
2867
-						// et ne pas enregistrer de cache
2868
-						if (!defined('_VAR_NOCACHE')) {
2869
-							define('_VAR_NOCACHE', true);
2870
-						}
2871
-						$var_mode = array_diff($var_mode, array('preview'));
2872
-					}
2873
-					if (in_array('inclure', $var_mode)) {
2874
-						// forcer le compilo et ignorer les caches existants
2875
-						if (!defined('_VAR_MODE')) {
2876
-							define('_VAR_MODE', 'calcul');
2877
-						}
2878
-						if (!defined('_VAR_INCLURE')) {
2879
-							define('_VAR_INCLURE', true);
2880
-						}
2881
-						// et ne pas enregistrer de cache
2882
-						if (!defined('_VAR_NOCACHE')) {
2883
-							define('_VAR_NOCACHE', true);
2884
-						}
2885
-						$var_mode = array_diff($var_mode, array('inclure'));
2886
-					}
2887
-					if (in_array('urls', $var_mode)) {
2888
-						// forcer le compilo et ignorer les caches existants
2889
-						if (!defined('_VAR_MODE')) {
2890
-							define('_VAR_MODE', 'calcul');
2891
-						}
2892
-						if (!defined('_VAR_URLS')) {
2893
-							define('_VAR_URLS', true);
2894
-						}
2895
-						$var_mode = array_diff($var_mode, array('urls'));
2896
-					}
2897
-					if (in_array('images', $var_mode)) {
2898
-						// forcer le compilo et ignorer les caches existants
2899
-						if (!defined('_VAR_MODE')) {
2900
-							define('_VAR_MODE', 'calcul');
2901
-						}
2902
-						// indiquer qu'on doit recalculer les images
2903
-						if (!defined('_VAR_IMAGES')) {
2904
-							define('_VAR_IMAGES', true);
2905
-						}
2906
-						$var_mode = array_diff($var_mode, array('images'));
2907
-					}
2908
-					if (in_array('debug', $var_mode)) {
2909
-						if (!defined('_VAR_MODE')) {
2910
-							define('_VAR_MODE', 'debug');
2911
-						}
2912
-						// et ne pas enregistrer de cache
2913
-						if (!defined('_VAR_NOCACHE')) {
2914
-							define('_VAR_NOCACHE', true);
2915
-						}
2916
-						$var_mode = array_diff($var_mode, array('debug'));
2917
-					}
2918
-					if (count($var_mode) and !defined('_VAR_MODE')) {
2919
-						define('_VAR_MODE', reset($var_mode));
2920
-					}
2921
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
2922
-						spip_log($GLOBALS['visiteur_session']['nom']
2923
-							. " " . _VAR_MODE);
2924
-					}
2925
-				} // pas autorise ?
2926
-				else {
2927
-					// si on n'est pas connecte on se redirige
2928
-					if (!$GLOBALS['visiteur_session']) {
2929
-						include_spip('inc/headers');
2930
-						redirige_par_entete(generer_url_public('login',
2931
-							'url=' . rawurlencode(
2932
-								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2933
-							), true));
2934
-					}
2935
-					// sinon tant pis
2936
-				}
2937
-			}
2938
-		}
2939
-		if (!defined('_VAR_MODE')) {
2940
-			/**
2941
-			 * Indique le mode de calcul ou d'affichage de la page.
2942
-			 * @see init_var_mode()
2943
-			 */
2944
-			define('_VAR_MODE', false);
2945
-		}
2946
-		$done = true;
2947
-	}
2824
+    static $done = false;
2825
+    if (!$done) {
2826
+
2827
+        if (isset($_GET['var_mode'])) {
2828
+            $var_mode = explode(',', $_GET['var_mode']);
2829
+            // tout le monde peut calcul/recalcul
2830
+            if (!defined('_VAR_MODE')) {
2831
+                if (in_array('recalcul', $var_mode)) {
2832
+                    define('_VAR_MODE', 'recalcul');
2833
+                } elseif (in_array('calcul', $var_mode)) {
2834
+                    define('_VAR_MODE', 'calcul');
2835
+                }
2836
+            }
2837
+            $var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2838
+            if ($var_mode) {
2839
+                include_spip('inc/autoriser');
2840
+                // autoriser preview si preview seulement, et sinon autoriser debug
2841
+                if (autoriser(
2842
+                    ($_GET['var_mode'] == 'preview')
2843
+                        ? 'previsualiser'
2844
+                        : 'debug'
2845
+                )) {
2846
+                    if (in_array('traduction', $var_mode)) {
2847
+                        // forcer le calcul pour passer dans traduire
2848
+                        if (!defined('_VAR_MODE')) {
2849
+                            define('_VAR_MODE', 'calcul');
2850
+                        }
2851
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2852
+                        if (!defined('_VAR_NOCACHE')) {
2853
+                            define('_VAR_NOCACHE', true);
2854
+                        }
2855
+                        $var_mode = array_diff($var_mode, array('traduction'));
2856
+                    }
2857
+                    if (in_array('preview', $var_mode)) {
2858
+                        // basculer sur les criteres de preview dans les boucles
2859
+                        if (!defined('_VAR_PREVIEW')) {
2860
+                            define('_VAR_PREVIEW', true);
2861
+                        }
2862
+                        // forcer le calcul
2863
+                        if (!defined('_VAR_MODE')) {
2864
+                            define('_VAR_MODE', 'calcul');
2865
+                        }
2866
+                        // et ne pas enregistrer de cache
2867
+                        if (!defined('_VAR_NOCACHE')) {
2868
+                            define('_VAR_NOCACHE', true);
2869
+                        }
2870
+                        $var_mode = array_diff($var_mode, array('preview'));
2871
+                    }
2872
+                    if (in_array('inclure', $var_mode)) {
2873
+                        // forcer le compilo et ignorer les caches existants
2874
+                        if (!defined('_VAR_MODE')) {
2875
+                            define('_VAR_MODE', 'calcul');
2876
+                        }
2877
+                        if (!defined('_VAR_INCLURE')) {
2878
+                            define('_VAR_INCLURE', true);
2879
+                        }
2880
+                        // et ne pas enregistrer de cache
2881
+                        if (!defined('_VAR_NOCACHE')) {
2882
+                            define('_VAR_NOCACHE', true);
2883
+                        }
2884
+                        $var_mode = array_diff($var_mode, array('inclure'));
2885
+                    }
2886
+                    if (in_array('urls', $var_mode)) {
2887
+                        // forcer le compilo et ignorer les caches existants
2888
+                        if (!defined('_VAR_MODE')) {
2889
+                            define('_VAR_MODE', 'calcul');
2890
+                        }
2891
+                        if (!defined('_VAR_URLS')) {
2892
+                            define('_VAR_URLS', true);
2893
+                        }
2894
+                        $var_mode = array_diff($var_mode, array('urls'));
2895
+                    }
2896
+                    if (in_array('images', $var_mode)) {
2897
+                        // forcer le compilo et ignorer les caches existants
2898
+                        if (!defined('_VAR_MODE')) {
2899
+                            define('_VAR_MODE', 'calcul');
2900
+                        }
2901
+                        // indiquer qu'on doit recalculer les images
2902
+                        if (!defined('_VAR_IMAGES')) {
2903
+                            define('_VAR_IMAGES', true);
2904
+                        }
2905
+                        $var_mode = array_diff($var_mode, array('images'));
2906
+                    }
2907
+                    if (in_array('debug', $var_mode)) {
2908
+                        if (!defined('_VAR_MODE')) {
2909
+                            define('_VAR_MODE', 'debug');
2910
+                        }
2911
+                        // et ne pas enregistrer de cache
2912
+                        if (!defined('_VAR_NOCACHE')) {
2913
+                            define('_VAR_NOCACHE', true);
2914
+                        }
2915
+                        $var_mode = array_diff($var_mode, array('debug'));
2916
+                    }
2917
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
2918
+                        define('_VAR_MODE', reset($var_mode));
2919
+                    }
2920
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
2921
+                        spip_log($GLOBALS['visiteur_session']['nom']
2922
+                            . " " . _VAR_MODE);
2923
+                    }
2924
+                } // pas autorise ?
2925
+                else {
2926
+                    // si on n'est pas connecte on se redirige
2927
+                    if (!$GLOBALS['visiteur_session']) {
2928
+                        include_spip('inc/headers');
2929
+                        redirige_par_entete(generer_url_public('login',
2930
+                            'url=' . rawurlencode(
2931
+                                parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2932
+                            ), true));
2933
+                    }
2934
+                    // sinon tant pis
2935
+                }
2936
+            }
2937
+        }
2938
+        if (!defined('_VAR_MODE')) {
2939
+            /**
2940
+             * Indique le mode de calcul ou d'affichage de la page.
2941
+             * @see init_var_mode()
2942
+             */
2943
+            define('_VAR_MODE', false);
2944
+        }
2945
+        $done = true;
2946
+    }
2948 2947
 }
2949 2948
 
2950 2949
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
@@ -2952,85 +2951,85 @@  discard block
 block discarded – undo
2952 2951
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
2953 2952
 // https://code.spip.net/@spip_desinfecte
2954 2953
 function spip_desinfecte(&$t, $deep = true) {
2955
-	foreach ($t as $key => $val) {
2956
-		if (is_string($t[$key])) {
2957
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
2958
-		} // traiter aussi les "texte_plus" de article_edit
2959
-		else {
2960
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2961
-				spip_desinfecte($t[$key], $deep);
2962
-			}
2963
-		}
2964
-	}
2954
+    foreach ($t as $key => $val) {
2955
+        if (is_string($t[$key])) {
2956
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
2957
+        } // traiter aussi les "texte_plus" de article_edit
2958
+        else {
2959
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2960
+                spip_desinfecte($t[$key], $deep);
2961
+            }
2962
+        }
2963
+    }
2965 2964
 }
2966 2965
 
2967 2966
 //  retourne le statut du visiteur s'il s'annonce
2968 2967
 
2969 2968
 // https://code.spip.net/@verifier_visiteur
2970 2969
 function verifier_visiteur() {
2971
-	// Rq: pour que cette fonction marche depuis mes_options
2972
-	// il faut forcer l'init si ce n'est fait
2973
-	// mais on risque de perturber des plugins en initialisant trop tot
2974
-	// certaines constantes
2975
-	@spip_initialisation_core(
2976
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2977
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2978
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2979
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2980
-	);
2981
-
2982
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
2983
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
2984
-	// Attention on separe bien session_nom et nom, pour eviter
2985
-	// les melanges entre donnees SQL et variables plus aleatoires
2986
-	$variables_session = array('session_nom', 'session_email');
2987
-	foreach ($variables_session as $var) {
2988
-		if (_request($var) !== null) {
2989
-			$init = true;
2990
-			break;
2991
-		}
2992
-	}
2993
-	if (isset($init)) {
2994
-		#@spip_initialisation_suite();
2995
-		$session = charger_fonction('session', 'inc');
2996
-		$session();
2997
-		include_spip('inc/texte');
2998
-		foreach ($variables_session as $var) {
2999
-			if (($a = _request($var)) !== null) {
3000
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3001
-			}
3002
-		}
3003
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3004
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3005
-		}
3006
-		$session($GLOBALS['visiteur_session']);
3007
-
3008
-		return 0;
3009
-	}
3010
-
3011
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3012
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3013
-
3014
-		$session = charger_fonction('session', 'inc');
3015
-		if ($session()) {
3016
-			return $GLOBALS['visiteur_session']['statut'];
3017
-		}
3018
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3019
-			include_spip('inc/auth');
3020
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3021
-		}
3022
-		if ($h) {
3023
-			$GLOBALS['visiteur_session'] = $h;
3024
-
3025
-			return $GLOBALS['visiteur_session']['statut'];
3026
-		}
3027
-	}
3028
-
3029
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3030
-	include_spip('inc/lang');
3031
-	utiliser_langue_visiteur();
3032
-
3033
-	return false;
2970
+    // Rq: pour que cette fonction marche depuis mes_options
2971
+    // il faut forcer l'init si ce n'est fait
2972
+    // mais on risque de perturber des plugins en initialisant trop tot
2973
+    // certaines constantes
2974
+    @spip_initialisation_core(
2975
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2976
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2977
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2978
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2979
+    );
2980
+
2981
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
2982
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
2983
+    // Attention on separe bien session_nom et nom, pour eviter
2984
+    // les melanges entre donnees SQL et variables plus aleatoires
2985
+    $variables_session = array('session_nom', 'session_email');
2986
+    foreach ($variables_session as $var) {
2987
+        if (_request($var) !== null) {
2988
+            $init = true;
2989
+            break;
2990
+        }
2991
+    }
2992
+    if (isset($init)) {
2993
+        #@spip_initialisation_suite();
2994
+        $session = charger_fonction('session', 'inc');
2995
+        $session();
2996
+        include_spip('inc/texte');
2997
+        foreach ($variables_session as $var) {
2998
+            if (($a = _request($var)) !== null) {
2999
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3000
+            }
3001
+        }
3002
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3003
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3004
+        }
3005
+        $session($GLOBALS['visiteur_session']);
3006
+
3007
+        return 0;
3008
+    }
3009
+
3010
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3011
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3012
+
3013
+        $session = charger_fonction('session', 'inc');
3014
+        if ($session()) {
3015
+            return $GLOBALS['visiteur_session']['statut'];
3016
+        }
3017
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3018
+            include_spip('inc/auth');
3019
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3020
+        }
3021
+        if ($h) {
3022
+            $GLOBALS['visiteur_session'] = $h;
3023
+
3024
+            return $GLOBALS['visiteur_session']['statut'];
3025
+        }
3026
+    }
3027
+
3028
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3029
+    include_spip('inc/lang');
3030
+    utiliser_langue_visiteur();
3031
+
3032
+    return false;
3034 3033
 }
3035 3034
 
3036 3035
 
@@ -3053,21 +3052,21 @@  discard block
 block discarded – undo
3053 3052
  *     - string Langue utilisée.
3054 3053
  **/
3055 3054
 function lang_select($lang = null) {
3056
-	static $pile_langues = array();
3057
-	if (!function_exists('changer_langue')) {
3058
-		include_spip('inc/lang');
3059
-	}
3060
-	if ($lang === null) {
3061
-		$lang = array_pop($pile_langues);
3062
-	} else {
3063
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3064
-	}
3065
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3066
-		return $lang;
3067
-	}
3068
-	changer_langue($lang);
3055
+    static $pile_langues = array();
3056
+    if (!function_exists('changer_langue')) {
3057
+        include_spip('inc/lang');
3058
+    }
3059
+    if ($lang === null) {
3060
+        $lang = array_pop($pile_langues);
3061
+    } else {
3062
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3063
+    }
3064
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3065
+        return $lang;
3066
+    }
3067
+    changer_langue($lang);
3069 3068
 
3070
-	return $lang;
3069
+    return $lang;
3071 3070
 }
3072 3071
 
3073 3072
 /**
@@ -3084,19 +3083,19 @@  discard block
 block discarded – undo
3084 3083
  *     Identifiant de la session
3085 3084
  **/
3086 3085
 function spip_session($force = false) {
3087
-	static $session;
3088
-	if ($force or !isset($session)) {
3089
-		$s = pipeline('definir_session',
3090
-			$GLOBALS['visiteur_session']
3091
-				? serialize($GLOBALS['visiteur_session'])
3092
-				. '_' . @$_COOKIE['spip_session']
3093
-				: ''
3094
-		);
3095
-		$session = $s ? substr(md5($s), 0, 8) : '';
3096
-	}
3086
+    static $session;
3087
+    if ($force or !isset($session)) {
3088
+        $s = pipeline('definir_session',
3089
+            $GLOBALS['visiteur_session']
3090
+                ? serialize($GLOBALS['visiteur_session'])
3091
+                . '_' . @$_COOKIE['spip_session']
3092
+                : ''
3093
+        );
3094
+        $session = $s ? substr(md5($s), 0, 8) : '';
3095
+    }
3097 3096
 
3098
-	#spip_log('session: '.$session);
3099
-	return $session;
3097
+    #spip_log('session: '.$session);
3098
+    return $session;
3100 3099
 }
3101 3100
 
3102 3101
 
@@ -3115,9 +3114,9 @@  discard block
 block discarded – undo
3115 3114
  *    Lien sur une icone d'aide
3116 3115
  **/
3117 3116
 function aider($aide = '', $distante = false) {
3118
-	$aider = charger_fonction('aide', 'inc', true);
3117
+    $aider = charger_fonction('aide', 'inc', true);
3119 3118
 
3120
-	return $aider ? $aider($aide, '', array(), $distante) : '';
3119
+    return $aider ? $aider($aide, '', array(), $distante) : '';
3121 3120
 }
3122 3121
 
3123 3122
 /**
@@ -3127,24 +3126,24 @@  discard block
 block discarded – undo
3127 3126
  */
3128 3127
 function exec_info_dist() {
3129 3128
 
3130
-	include_spip('inc/autoriser');
3131
-	if (autoriser('webmestre')) {
3132
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3133
-		$cookies_backup = [];
3134
-		foreach ($cookies_masques as $k) {
3135
-			if (!empty($_COOKIE[$k])) {
3136
-				$cookies_backup[$k] = $_COOKIE[$k];
3137
-				$_COOKIE[$k] = '******************************';
3138
-			}
3139
-		}
3140
-		phpinfo();
3141
-		foreach ($cookies_backup as $k => $v) {
3142
-			$_COOKIE[$k] = $v;
3143
-		}
3144
-	} else {
3145
-		include_spip('inc/filtres');
3146
-		sinon_interdire_acces();
3147
-	}
3129
+    include_spip('inc/autoriser');
3130
+    if (autoriser('webmestre')) {
3131
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3132
+        $cookies_backup = [];
3133
+        foreach ($cookies_masques as $k) {
3134
+            if (!empty($_COOKIE[$k])) {
3135
+                $cookies_backup[$k] = $_COOKIE[$k];
3136
+                $_COOKIE[$k] = '******************************';
3137
+            }
3138
+        }
3139
+        phpinfo();
3140
+        foreach ($cookies_backup as $k => $v) {
3141
+            $_COOKIE[$k] = $v;
3142
+        }
3143
+    } else {
3144
+        include_spip('inc/filtres');
3145
+        sinon_interdire_acces();
3146
+    }
3148 3147
 }
3149 3148
 
3150 3149
 /**
@@ -3164,13 +3163,13 @@  discard block
 block discarded – undo
3164 3163
  *     - string si $message à false.
3165 3164
  **/
3166 3165
 function erreur_squelette($message = '', $lieu = '') {
3167
-	$debusquer = charger_fonction('debusquer', 'public');
3168
-	if (is_array($lieu)) {
3169
-		include_spip('public/compiler');
3170
-		$lieu = reconstruire_contexte_compil($lieu);
3171
-	}
3166
+    $debusquer = charger_fonction('debusquer', 'public');
3167
+    if (is_array($lieu)) {
3168
+        include_spip('public/compiler');
3169
+        $lieu = reconstruire_contexte_compil($lieu);
3170
+    }
3172 3171
 
3173
-	return $debusquer($message, $lieu);
3172
+    return $debusquer($message, $lieu);
3174 3173
 }
3175 3174
 
3176 3175
 /**
@@ -3207,109 +3206,109 @@  discard block
 block discarded – undo
3207 3206
  *     - ou tableau d'information sur le squelette.
3208 3207
  */
3209 3208
 function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') {
3210
-	if (!function_exists('evaluer_fond')) {
3211
-		include_spip('public/assembler');
3212
-	}
3213
-	// assurer la compat avec l'ancienne syntaxe
3214
-	// (trim etait le 3eme argument, par defaut a true)
3215
-	if (!is_array($options)) {
3216
-		$options = array('trim' => $options);
3217
-	}
3218
-	if (!isset($options['trim'])) {
3219
-		$options['trim'] = true;
3220
-	}
3221
-
3222
-	if (isset($contexte['connect'])) {
3223
-		$connect = $contexte['connect'];
3224
-		unset($contexte['connect']);
3225
-	}
3226
-
3227
-	$texte = "";
3228
-	$pages = array();
3229
-	$lang_select = '';
3230
-	if (!isset($options['etoile']) or !$options['etoile']) {
3231
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3232
-		if (!isset($contexte['lang'])) {
3233
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3234
-		}
3235
-
3236
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3237
-			$lang_select = lang_select($contexte['lang']);
3238
-		}
3239
-	}
3240
-
3241
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3242
-		$GLOBALS['_INC_PUBLIC'] = 0;
3243
-	}
3244
-
3245
-	$GLOBALS['_INC_PUBLIC']++;
3246
-
3247
-	// fix #4235
3248
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3249
-
3250
-
3251
-	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3209
+    if (!function_exists('evaluer_fond')) {
3210
+        include_spip('public/assembler');
3211
+    }
3212
+    // assurer la compat avec l'ancienne syntaxe
3213
+    // (trim etait le 3eme argument, par defaut a true)
3214
+    if (!is_array($options)) {
3215
+        $options = array('trim' => $options);
3216
+    }
3217
+    if (!isset($options['trim'])) {
3218
+        $options['trim'] = true;
3219
+    }
3220
+
3221
+    if (isset($contexte['connect'])) {
3222
+        $connect = $contexte['connect'];
3223
+        unset($contexte['connect']);
3224
+    }
3225
+
3226
+    $texte = "";
3227
+    $pages = array();
3228
+    $lang_select = '';
3229
+    if (!isset($options['etoile']) or !$options['etoile']) {
3230
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3231
+        if (!isset($contexte['lang'])) {
3232
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3233
+        }
3234
+
3235
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3236
+            $lang_select = lang_select($contexte['lang']);
3237
+        }
3238
+    }
3239
+
3240
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3241
+        $GLOBALS['_INC_PUBLIC'] = 0;
3242
+    }
3243
+
3244
+    $GLOBALS['_INC_PUBLIC']++;
3245
+
3246
+    // fix #4235
3247
+    $cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3248
+
3249
+
3250
+    foreach (is_array($fond) ? $fond : array($fond) as $f) {
3252 3251
 		
3253
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3254
-
3255
-		$page = evaluer_fond($f, $contexte, $connect);
3256
-		if ($page === '') {
3257
-			$c = isset($options['compil']) ? $options['compil'] : '';
3258
-			$a = array('fichier' => $f);
3259
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3260
-			erreur_squelette($erreur, $c);
3261
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3262
-			$page = array('texte' => '', 'erreur' => $erreur);
3263
-		}
3264
-
3265
-		$page = pipeline('recuperer_fond', array(
3266
-			'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3267
-			'data' => $page
3268
-		));
3269
-		if (isset($options['ajax']) and $options['ajax']) {
3270
-			if (!function_exists('encoder_contexte_ajax')) {
3271
-				include_spip('inc/filtres');
3272
-			}
3273
-			$page['texte'] = encoder_contexte_ajax(
3274
-				array_merge(
3275
-					$contexte,
3276
-					array('fond' => $f),
3277
-					($connect ? array('connect' => $connect) : array())
3278
-				),
3279
-				'',
3280
-				$page['texte'],
3281
-				$options['ajax']
3282
-			);
3283
-		}
3284
-
3285
-		if (isset($options['raw']) and $options['raw']) {
3286
-			$pages[] = $page;
3287
-		} else {
3288
-			$texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3289
-		}
3252
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3253
+
3254
+        $page = evaluer_fond($f, $contexte, $connect);
3255
+        if ($page === '') {
3256
+            $c = isset($options['compil']) ? $options['compil'] : '';
3257
+            $a = array('fichier' => $f);
3258
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3259
+            erreur_squelette($erreur, $c);
3260
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3261
+            $page = array('texte' => '', 'erreur' => $erreur);
3262
+        }
3263
+
3264
+        $page = pipeline('recuperer_fond', array(
3265
+            'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3266
+            'data' => $page
3267
+        ));
3268
+        if (isset($options['ajax']) and $options['ajax']) {
3269
+            if (!function_exists('encoder_contexte_ajax')) {
3270
+                include_spip('inc/filtres');
3271
+            }
3272
+            $page['texte'] = encoder_contexte_ajax(
3273
+                array_merge(
3274
+                    $contexte,
3275
+                    array('fond' => $f),
3276
+                    ($connect ? array('connect' => $connect) : array())
3277
+                ),
3278
+                '',
3279
+                $page['texte'],
3280
+                $options['ajax']
3281
+            );
3282
+        }
3283
+
3284
+        if (isset($options['raw']) and $options['raw']) {
3285
+            $pages[] = $page;
3286
+        } else {
3287
+            $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3288
+        }
3290 3289
 		
3291
-		// contamination de la session appelante, pour les inclusions statiques
3292
-		if (isset($page['invalideurs']['session'])){
3293
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3294
-		}
3295
-	}
3290
+        // contamination de la session appelante, pour les inclusions statiques
3291
+        if (isset($page['invalideurs']['session'])){
3292
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3293
+        }
3294
+    }
3296 3295
 
3297
-	// restaurer le sessionnement du contexte appelant, 
3298
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3299
-	if (isset($cache_utilise_session_appelant)) {
3300
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3301
-	}
3296
+    // restaurer le sessionnement du contexte appelant, 
3297
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3298
+    if (isset($cache_utilise_session_appelant)) {
3299
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3300
+    }
3302 3301
 
3303
-	$GLOBALS['_INC_PUBLIC']--;
3302
+    $GLOBALS['_INC_PUBLIC']--;
3304 3303
 
3305
-	if ($lang_select) {
3306
-		lang_select();
3307
-	}
3308
-	if (isset($options['raw']) and $options['raw']) {
3309
-		return is_array($fond) ? $pages : reset($pages);
3310
-	} else {
3311
-		return $options['trim'] ? ltrim($texte) : $texte;
3312
-	}
3304
+    if ($lang_select) {
3305
+        lang_select();
3306
+    }
3307
+    if (isset($options['raw']) and $options['raw']) {
3308
+        return is_array($fond) ? $pages : reset($pages);
3309
+    } else {
3310
+        return $options['trim'] ? ltrim($texte) : $texte;
3311
+    }
3313 3312
 }
3314 3313
 
3315 3314
 /**
@@ -3319,7 +3318,7 @@  discard block
 block discarded – undo
3319 3318
  * @return string
3320 3319
  */
3321 3320
 function trouve_modele($nom) {
3322
-	return trouver_fond($nom, 'modeles/');
3321
+    return trouver_fond($nom, 'modeles/');
3323 3322
 }
3324 3323
 
3325 3324
 /**
@@ -3335,21 +3334,21 @@  discard block
 block discarded – undo
3335 3334
  * @return array|string
3336 3335
  */
3337 3336
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3338
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3339
-	if (!$pathinfo) {
3340
-		return $f;
3341
-	}
3342
-	// renvoyer un tableau detaille si $pathinfo==true
3343
-	$p = pathinfo($f);
3344
-	if (!isset($p['extension']) or !$p['extension']) {
3345
-		$p['extension'] = _EXTENSION_SQUELETTES;
3346
-	}
3347
-	if (!isset($p['extension']) or !$p['filename']) {
3348
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3349
-	}
3350
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3337
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3338
+    if (!$pathinfo) {
3339
+        return $f;
3340
+    }
3341
+    // renvoyer un tableau detaille si $pathinfo==true
3342
+    $p = pathinfo($f);
3343
+    if (!isset($p['extension']) or !$p['extension']) {
3344
+        $p['extension'] = _EXTENSION_SQUELETTES;
3345
+    }
3346
+    if (!isset($p['extension']) or !$p['filename']) {
3347
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3348
+    }
3349
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3351 3350
 
3352
-	return $p;
3351
+    return $p;
3353 3352
 }
3354 3353
 
3355 3354
 /**
@@ -3370,24 +3369,24 @@  discard block
 block discarded – undo
3370 3369
  *     Nom de l'exec, sinon chaîne vide.
3371 3370
  **/
3372 3371
 function tester_url_ecrire($nom) {
3373
-	static $exec = array();
3374
-	if (isset($exec[$nom])) {
3375
-		return $exec[$nom];
3376
-	}
3377
-	// tester si c'est une page en squelette
3378
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3379
-		return $exec[$nom] = 'fond';
3380
-	} // compat skels orthogonaux version precedente
3381
-	elseif (trouver_fond($nom, 'prive/exec/')) {
3382
-		return $exec[$nom] = 'fond_monobloc';
3383
-	} // echafaudage d'un fond !
3384
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3385
-		return $exec[$nom] = 'fond';
3386
-	}
3387
-	// attention, il ne faut pas inclure l'exec ici
3388
-	// car sinon #URL_ECRIRE provoque des inclusions
3389
-	// et des define intrusifs potentiels
3390
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3372
+    static $exec = array();
3373
+    if (isset($exec[$nom])) {
3374
+        return $exec[$nom];
3375
+    }
3376
+    // tester si c'est une page en squelette
3377
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3378
+        return $exec[$nom] = 'fond';
3379
+    } // compat skels orthogonaux version precedente
3380
+    elseif (trouver_fond($nom, 'prive/exec/')) {
3381
+        return $exec[$nom] = 'fond_monobloc';
3382
+    } // echafaudage d'un fond !
3383
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3384
+        return $exec[$nom] = 'fond';
3385
+    }
3386
+    // attention, il ne faut pas inclure l'exec ici
3387
+    // car sinon #URL_ECRIRE provoque des inclusions
3388
+    // et des define intrusifs potentiels
3389
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3391 3390
 }
3392 3391
 
3393 3392
 
@@ -3403,10 +3402,10 @@  discard block
 block discarded – undo
3403 3402
  * @return bool true si le module est chargé
3404 3403
  **/
3405 3404
 function charger_php_extension($module) {
3406
-	if (extension_loaded($module)) {
3407
-		return true;
3408
-	}
3409
-	return false;
3405
+    if (extension_loaded($module)) {
3406
+        return true;
3407
+    }
3408
+    return false;
3410 3409
 }
3411 3410
 
3412 3411
 
@@ -3417,8 +3416,8 @@  discard block
 block discarded – undo
3417 3416
  *     true si et seulement si la configuration autorise le code HTML5 sur le site public
3418 3417
  **/
3419 3418
 function html5_permis() {
3420
-	return (isset($GLOBALS['meta']['version_html_max'])
3421
-		and ('html5' == $GLOBALS['meta']['version_html_max']));
3419
+    return (isset($GLOBALS['meta']['version_html_max'])
3420
+        and ('html5' == $GLOBALS['meta']['version_html_max']));
3422 3421
 }
3423 3422
 
3424 3423
 /**
@@ -3428,17 +3427,17 @@  discard block
 block discarded – undo
3428 3427
  * @return array
3429 3428
  */
3430 3429
 function formats_image_acceptables($gd = false, $svg_allowed = true) {
3431
-	$config = ($gd ? "gd_formats" : "formats_graphiques");
3432
-	$formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg');
3433
-	$formats = explode(',', $formats);
3434
-	$formats = array_filter($formats);
3435
-	$formats = array_map('trim', $formats);
3430
+    $config = ($gd ? "gd_formats" : "formats_graphiques");
3431
+    $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg');
3432
+    $formats = explode(',', $formats);
3433
+    $formats = array_filter($formats);
3434
+    $formats = array_map('trim', $formats);
3436 3435
 
3437
-	if ($svg_allowed) {
3438
-		$formats[] = 'svg';
3439
-	}
3436
+    if ($svg_allowed) {
3437
+        $formats[] = 'svg';
3438
+    }
3440 3439
 
3441
-	return $formats;
3440
+    return $formats;
3442 3441
 }
3443 3442
 
3444 3443
 /**
@@ -3447,21 +3446,21 @@  discard block
 block discarded – undo
3447 3446
  * @return array|bool
3448 3447
  */
3449 3448
 function spip_getimagesize($fichier) {
3450
-	if (!$imagesize = @getimagesize($fichier)) {
3449
+    if (!$imagesize = @getimagesize($fichier)) {
3451 3450
 
3452
-		include_spip("inc/svg");
3453
-		if ($attrs = svg_lire_attributs($fichier)) {
3454
-			list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3455
-			$imagesize = [
3456
-				$width,
3457
-				$height,
3458
-				IMAGETYPE_SVG,
3459
-				"width=\"{$width}\" height=\"{$height}\"",
3460
-				"mime" => "image/svg+xml"
3461
-			];
3462
-		}
3463
-	}
3464
-	return $imagesize;
3451
+        include_spip("inc/svg");
3452
+        if ($attrs = svg_lire_attributs($fichier)) {
3453
+            list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3454
+            $imagesize = [
3455
+                $width,
3456
+                $height,
3457
+                IMAGETYPE_SVG,
3458
+                "width=\"{$width}\" height=\"{$height}\"",
3459
+                "mime" => "image/svg+xml"
3460
+            ];
3461
+        }
3462
+    }
3463
+    return $imagesize;
3465 3464
 }
3466 3465
 
3467 3466
 
@@ -3481,7 +3480,7 @@  discard block
 block discarded – undo
3481 3480
  * @return mixed Valeur de la meta.
3482 3481
  **/
3483 3482
 function lire_meta($nom) {
3484
-	return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3483
+    return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3485 3484
 }
3486 3485
 
3487 3486
 
@@ -3503,130 +3502,130 @@  discard block
 block discarded – undo
3503 3502
  * @param string $statut
3504 3503
  */
3505 3504
 function avertir_auteurs($nom, $message, $statut = '') {
3506
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3507
-	if (!$alertes
3508
-		or !is_array($alertes = unserialize($alertes))
3509
-	) {
3510
-		$alertes = array();
3511
-	}
3505
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3506
+    if (!$alertes
3507
+        or !is_array($alertes = unserialize($alertes))
3508
+    ) {
3509
+        $alertes = array();
3510
+    }
3512 3511
 
3513
-	if (!isset($alertes[$statut])) {
3514
-		$alertes[$statut] = array();
3515
-	}
3516
-	$alertes[$statut][$nom] = $message;
3517
-	ecrire_meta("message_alertes_auteurs", serialize($alertes));
3512
+    if (!isset($alertes[$statut])) {
3513
+        $alertes[$statut] = array();
3514
+    }
3515
+    $alertes[$statut][$nom] = $message;
3516
+    ecrire_meta("message_alertes_auteurs", serialize($alertes));
3518 3517
 }
3519 3518
 
3520 3519
 if (PHP_VERSION_ID < 50500) {
3521
-	if (!function_exists('array_column')) {
3522
-		/**
3523
-		 * Returns the values from a single column of the input array, identified by
3524
-		 * the $columnKey.
3525
-		 *
3526
-		 * Optionally, you may provide an $indexKey to index the values in the returned
3527
-		 * array by the values from the $indexKey column in the input array.
3528
-		 *
3529
-		 * @link http://php.net/manual/fr/function.array-column.php
3530
-		 * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3531
-		 * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3532
-		 * @license http://opensource.org/licenses/MIT MIT
3533
-		 *
3534
-		 * @param array $input A multi-dimensional array (record set) from which to pull
3535
-		 *                     a column of values.
3536
-		 * @param mixed $columnKey The column of values to return. This value may be the
3537
-		 *                         integer key of the column you wish to retrieve, or it
3538
-		 *                         may be the string key name for an associative array.
3539
-		 * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3540
-		 *                        the returned array. This value may be the integer key
3541
-		 *                        of the column, or it may be the string key name.
3542
-		 * @return array
3543
-		 */
3544
-		function array_column($input = null, $columnKey = null, $indexKey = null)
3545
-		{
3546
-			// Using func_get_args() in order to check for proper number of
3547
-			// parameters and trigger errors exactly as the built-in array_column()
3548
-			// does in PHP 5.5.
3549
-			$argc = func_num_args();
3550
-			$params = func_get_args();
3551
-
3552
-			if ($argc < 2) {
3553
-				trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3554
-				return null;
3555
-			}
3556
-
3557
-			if (!is_array($params[0])) {
3558
-				trigger_error(
3559
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3560
-					E_USER_WARNING
3561
-				);
3562
-				return null;
3563
-			}
3564
-
3565
-			if (!is_int($params[1])
3566
-				&& !is_float($params[1])
3567
-				&& !is_string($params[1])
3568
-				&& $params[1] !== null
3569
-				&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
3570
-			) {
3571
-				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3572
-				return false;
3573
-			}
3574
-
3575
-			if (isset($params[2])
3576
-				&& !is_int($params[2])
3577
-				&& !is_float($params[2])
3578
-				&& !is_string($params[2])
3579
-				&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
3580
-			) {
3581
-				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3582
-				return false;
3583
-			}
3584
-
3585
-			$paramsInput = $params[0];
3586
-			$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3587
-
3588
-			$paramsIndexKey = null;
3589
-			if (isset($params[2])) {
3590
-				if (is_float($params[2]) || is_int($params[2])) {
3591
-					$paramsIndexKey = (int) $params[2];
3592
-				} else {
3593
-					$paramsIndexKey = (string) $params[2];
3594
-				}
3595
-			}
3596
-
3597
-			$resultArray = array();
3598
-
3599
-			foreach ($paramsInput as $row) {
3600
-				$key = $value = null;
3601
-				$keySet = $valueSet = false;
3602
-
3603
-				if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3604
-					$keySet = true;
3605
-					$key = (string) $row[$paramsIndexKey];
3606
-				}
3607
-
3608
-				if ($paramsColumnKey === null) {
3609
-					$valueSet = true;
3610
-					$value = $row;
3611
-				} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3612
-					$valueSet = true;
3613
-					$value = $row[$paramsColumnKey];
3614
-				}
3615
-
3616
-				if ($valueSet) {
3617
-					if ($keySet) {
3618
-						$resultArray[$key] = $value;
3619
-					} else {
3620
-						$resultArray[] = $value;
3621
-					}
3622
-				}
3623
-
3624
-			}
3625
-
3626
-			return $resultArray;
3627
-		}
3628
-
3629
-	}
3520
+    if (!function_exists('array_column')) {
3521
+        /**
3522
+         * Returns the values from a single column of the input array, identified by
3523
+         * the $columnKey.
3524
+         *
3525
+         * Optionally, you may provide an $indexKey to index the values in the returned
3526
+         * array by the values from the $indexKey column in the input array.
3527
+         *
3528
+         * @link http://php.net/manual/fr/function.array-column.php
3529
+         * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3530
+         * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3531
+         * @license http://opensource.org/licenses/MIT MIT
3532
+         *
3533
+         * @param array $input A multi-dimensional array (record set) from which to pull
3534
+         *                     a column of values.
3535
+         * @param mixed $columnKey The column of values to return. This value may be the
3536
+         *                         integer key of the column you wish to retrieve, or it
3537
+         *                         may be the string key name for an associative array.
3538
+         * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3539
+         *                        the returned array. This value may be the integer key
3540
+         *                        of the column, or it may be the string key name.
3541
+         * @return array
3542
+         */
3543
+        function array_column($input = null, $columnKey = null, $indexKey = null)
3544
+        {
3545
+            // Using func_get_args() in order to check for proper number of
3546
+            // parameters and trigger errors exactly as the built-in array_column()
3547
+            // does in PHP 5.5.
3548
+            $argc = func_num_args();
3549
+            $params = func_get_args();
3550
+
3551
+            if ($argc < 2) {
3552
+                trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3553
+                return null;
3554
+            }
3555
+
3556
+            if (!is_array($params[0])) {
3557
+                trigger_error(
3558
+                    'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3559
+                    E_USER_WARNING
3560
+                );
3561
+                return null;
3562
+            }
3563
+
3564
+            if (!is_int($params[1])
3565
+                && !is_float($params[1])
3566
+                && !is_string($params[1])
3567
+                && $params[1] !== null
3568
+                && !(is_object($params[1]) && method_exists($params[1], '__toString'))
3569
+            ) {
3570
+                trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3571
+                return false;
3572
+            }
3573
+
3574
+            if (isset($params[2])
3575
+                && !is_int($params[2])
3576
+                && !is_float($params[2])
3577
+                && !is_string($params[2])
3578
+                && !(is_object($params[2]) && method_exists($params[2], '__toString'))
3579
+            ) {
3580
+                trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3581
+                return false;
3582
+            }
3583
+
3584
+            $paramsInput = $params[0];
3585
+            $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3586
+
3587
+            $paramsIndexKey = null;
3588
+            if (isset($params[2])) {
3589
+                if (is_float($params[2]) || is_int($params[2])) {
3590
+                    $paramsIndexKey = (int) $params[2];
3591
+                } else {
3592
+                    $paramsIndexKey = (string) $params[2];
3593
+                }
3594
+            }
3595
+
3596
+            $resultArray = array();
3597
+
3598
+            foreach ($paramsInput as $row) {
3599
+                $key = $value = null;
3600
+                $keySet = $valueSet = false;
3601
+
3602
+                if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3603
+                    $keySet = true;
3604
+                    $key = (string) $row[$paramsIndexKey];
3605
+                }
3606
+
3607
+                if ($paramsColumnKey === null) {
3608
+                    $valueSet = true;
3609
+                    $value = $row;
3610
+                } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3611
+                    $valueSet = true;
3612
+                    $value = $row[$paramsColumnKey];
3613
+                }
3614
+
3615
+                if ($valueSet) {
3616
+                    if ($keySet) {
3617
+                        $resultArray[$key] = $value;
3618
+                    } else {
3619
+                        $resultArray[] = $value;
3620
+                    }
3621
+                }
3622
+
3623
+            }
3624
+
3625
+            return $resultArray;
3626
+        }
3627
+
3628
+    }
3630 3629
 }
3631 3630
 
3632 3631
 /**
@@ -3640,8 +3639,8 @@  discard block
 block discarded – undo
3640 3639
  * @return string|string[]
3641 3640
  */
3642 3641
 function spip_sanitize_classname($classes) {
3643
-	if (is_array($classes)) {
3644
-		return array_map('spip_sanitize_classname', $classes);
3645
-	}
3646
-	return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes);
3642
+    if (is_array($classes)) {
3643
+        return array_map('spip_sanitize_classname', $classes);
3644
+    }
3645
+    return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes);
3647 3646
 }
3648 3647
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +130 added lines, -132 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
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81
-	if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
81
+	if (!$inc = include_spip($dossier.($d = strtolower($nom)))
82 82
 		// si le fichier truc/machin/nom.php n'existe pas,
83 83
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84 84
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
100
+	spip_log("fonction $nom ($f ou $g) indisponible".
101 101
 		($inc ? "" : " (fichier $d absent de $dossier)"));
102 102
 
103 103
 	include_spip('inc/minipres');
104 104
 	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
105
+		_T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')),
106
+		array('all_inline'=>true, 'status'=>404));
107 107
 	exit;
108 108
 }
109 109
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+	return find_in_path($f.'.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+	return find_in_path($f.'.php', '', 'required');
172 172
 }
173 173
 
174 174
 /**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 	// appliquer notre fonction si elle existe
263
-	$fonc = 'execute_pipeline_' . strtolower($action);
263
+	$fonc = 'execute_pipeline_'.strtolower($action);
264 264
 	if (function_exists($fonc)) {
265 265
 		$val = $fonc($val);
266 266
 	} // plantage ?
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 function spip_log($message = null, $name = null) {
325 325
 	static $pre = array();
326 326
 	static $log;
327
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
327
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
328 328
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
329 329
 		$logname = null;
330 330
 	}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		if (!is_string($message)) {
350 350
 			$message = print_r($message, true);
351 351
 		}
352
-		$log($pre[$niveau] . ' ' . $message, $logname);
352
+		$log($pre[$niveau].' '.$message, $logname);
353 353
 	}
354 354
 }
355 355
 
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
  * @param string $sanitize_function
463 463
  * @return array|mixed|string
464 464
  */
465
-function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') {
465
+function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
466 466
 	if (is_array($value)) {
467
-		if ($key=='*') {
467
+		if ($key == '*') {
468 468
 			$key = array_keys($value);
469 469
 		}
470 470
 		if (!is_array($key)) {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		$a = './';
550 550
 	}
551 551
 
552
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
552
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
553 553
 	$ajouts = array_flip(explode('|', $c));
554 554
 	$u = is_array($v) ? $v : rawurlencode($v);
555 555
 	$testv = (is_array($v) ? count($v) : strlen($v));
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 			// Ajout. Pour une variable, remplacer au meme endroit,
577 577
 			// pour un tableau ce sera fait dans la prochaine boucle
578 578
 			elseif (substr($r[1], -2) != '[]') {
579
-				$url[$n] = $r[1] . '=' . $u;
579
+				$url[$n] = $r[1].'='.$u;
580 580
 				unset($ajouts[$r[1]]);
581 581
 			}
582 582
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -596,11 +596,11 @@  discard block
 block discarded – undo
596 596
 	} elseif ($testv) {
597 597
 		foreach ($ajouts as $k => $n) {
598 598
 			if (!is_array($v)) {
599
-				$url[] = $k . '=' . $u;
599
+				$url[] = $k.'='.$u;
600 600
 			} else {
601
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
601
+				$id = (substr($k, -2) == '[]') ? $k : ($k."[]");
602 602
 				foreach ($v as $w) {
603
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
603
+					$url[] = $id.'='.(is_array($w) ? 'Array' : $w);
604 604
 				}
605 605
 			}
606 606
 		}
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 
612 612
 	// recomposer l'adresse
613 613
 	if ($url) {
614
-		$a .= '?' . join($sep, $url);
614
+		$a .= '?'.join($sep, $url);
615 615
 	}
616 616
 
617
-	return $a . $ancre;
617
+	return $a.$ancre;
618 618
 }
619 619
 
620 620
 /**
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 			translitteration($ancre)
647 647
 		);
648 648
 	}
649
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
649
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
650 650
 }
651 651
 
652 652
 /**
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
  * @return bool
759 759
  */
760 760
 function test_plugin_actif($plugin) {
761
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
761
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
762 762
 }
763 763
 
764 764
 /**
@@ -826,8 +826,7 @@  discard block
 block discarded – undo
826 826
 		// pour les chaines non traduites, assurer un service minimum
827 827
 		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
828 828
 			$text = str_replace('_', ' ',
829
-				(($n = strpos($text, ':')) === false ? $texte :
830
-					substr($texte, $n + 1)));
829
+				(($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1)));
831 830
 		}
832 831
 		$o['class'] = null;
833 832
 
@@ -899,7 +898,7 @@  discard block
 block discarded – undo
899 898
 		// Si des variables n'ont pas ete inserees, le signaler
900 899
 		// (chaines de langues pas a jour)
901 900
 		if ($args) {
902
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
901
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
903 902
 		}
904 903
 	}
905 904
 
@@ -923,7 +922,7 @@  discard block
 block discarded – undo
923 922
 function joli_repertoire($rep) {
924 923
 	$a = substr($rep, 0, 1);
925 924
 	if ($a <> '.' and $a <> '/') {
926
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
925
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
927 926
 	}
928 927
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
929 928
 
@@ -977,7 +976,7 @@  discard block
 block discarded – undo
977 976
 			$p -= ($x * 1000);
978 977
 		}
979 978
 
980
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
979
+		return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
981 980
 	}
982 981
 }
983 982
 
@@ -1046,7 +1045,7 @@  discard block
 block discarded – undo
1046 1045
 	if ($taches and count($taches) and !spip_connect()) {
1047 1046
 		return false;
1048 1047
 	}
1049
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1048
+	spip_log("cron !", 'jq'._LOG_DEBUG);
1050 1049
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1051 1050
 		return $genie($taches);
1052 1051
 	}
@@ -1150,7 +1149,7 @@  discard block
 block discarded – undo
1150 1149
 
1151 1150
 	if ($queue_next_job_time == -1) {
1152 1151
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1153
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1152
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt");
1154 1153
 		}
1155 1154
 		// utiliser un cache memoire si dispo
1156 1155
 		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1217,8 +1216,8 @@  discard block
 block discarded – undo
1217 1216
 		$src = '';
1218 1217
 	}
1219 1218
 	if ($script) {
1220
-		$script = ("/*<![CDATA[*/\n" .
1221
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1219
+		$script = ("/*<![CDATA[*/\n".
1220
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1222 1221
 			"/*]]>*/");
1223 1222
 	}
1224 1223
 	if ($noscript) {
@@ -1304,13 +1303,13 @@  discard block
 block discarded – undo
1304 1303
 	if ($path_base == null) {
1305 1304
 		// Chemin standard depuis l'espace public
1306 1305
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1307
-			_DIR_RACINE . ':' .
1308
-			_DIR_RACINE . 'squelettes-dist/:' .
1309
-			_DIR_RACINE . 'prive/:' .
1306
+			_DIR_RACINE.':'.
1307
+			_DIR_RACINE.'squelettes-dist/:'.
1308
+			_DIR_RACINE.'prive/:'.
1310 1309
 			_DIR_RESTREINT;
1311 1310
 		// Ajouter squelettes/
1312
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1313
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1311
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1312
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1314 1313
 		}
1315 1314
 		foreach (explode(':', $path) as $dir) {
1316 1315
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1322,7 +1321,7 @@  discard block
 block discarded – undo
1322 1321
 		// Et le(s) dossier(s) des squelettes nommes
1323 1322
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1324 1323
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1325
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1324
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1326 1325
 			}
1327 1326
 		}
1328 1327
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1333,7 +1332,7 @@  discard block
 block discarded – undo
1333 1332
 
1334 1333
 	if (strlen($dir_path)) {
1335 1334
 		$tete = "";
1336
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1335
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1337 1336
 			$tete = array_shift($path_base);
1338 1337
 		}
1339 1338
 		$dirs = array_reverse(explode(':', $dir_path));
@@ -1355,7 +1354,7 @@  discard block
 block discarded – undo
1355 1354
 	// Et le(s) dossier(s) des squelettes nommes
1356 1355
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1357 1356
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1358
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1357
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1359 1358
 		}
1360 1359
 	}
1361 1360
 
@@ -1425,9 +1424,9 @@  discard block
 block discarded – undo
1425 1424
 	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1426 1425
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1427 1426
 	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1428
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1427
+	  and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg"
1429 1428
 		and $f = find_in_theme("$file_svg_generique")) {
1430
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1429
+		if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) {
1431 1430
 			return $themefiles["$subdir$file"] = $fsize;
1432 1431
 		}
1433 1432
 		else {
@@ -1441,7 +1440,7 @@  discard block
 block discarded – undo
1441 1440
 			return $themefiles["$subdir$file"] = $f;
1442 1441
 		}
1443 1442
 	}
1444
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1443
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1445 1444
 
1446 1445
 	return $themefiles["$subdir$file"] = "";
1447 1446
 }
@@ -1469,7 +1468,7 @@  discard block
 block discarded – undo
1469 1468
 function chemin_image($icone) {
1470 1469
 	static $icone_renommer;
1471 1470
 	if ($p = strpos($icone, '?')) {
1472
-		$icone = substr($icone,0, $p);
1471
+		$icone = substr($icone, 0, $p);
1473 1472
 	}
1474 1473
 	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1475 1474
 	if (strpos($icone, "/") !== false and file_exists($icone)) {
@@ -1549,8 +1548,8 @@  discard block
 block discarded – undo
1549 1548
 			return false;
1550 1549
 		}
1551 1550
 		if ($include and !isset($inc[$dirname][$file])) {
1552
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1553
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1551
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1552
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1554 1553
 		}
1555 1554
 
1556 1555
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1563,14 +1562,14 @@  discard block
 block discarded – undo
1563 1562
 	}
1564 1563
 
1565 1564
 	foreach (creer_chemin() as $dir) {
1566
-		if (!isset($dirs[$a = $dir . $dirname])) {
1567
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1565
+		if (!isset($dirs[$a = $dir.$dirname])) {
1566
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1568 1567
 		}
1569 1568
 		if ($dirs[$a]) {
1570
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1569
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1571 1570
 				if ($include and !isset($inc[$dirname][$file])) {
1572
-					include_once _ROOT_CWD . $a;
1573
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1571
+					include_once _ROOT_CWD.$a;
1572
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1574 1573
 				}
1575 1574
 				if (!defined('_SAUVER_CHEMIN')) {
1576 1575
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1580,7 +1579,7 @@  discard block
 block discarded – undo
1580 1579
 					define('_SAUVER_CHEMIN', true);
1581 1580
 				}
1582 1581
 
1583
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1582
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1584 1583
 			}
1585 1584
 		}
1586 1585
 	}
@@ -1606,7 +1605,7 @@  discard block
 block discarded – undo
1606 1605
 		define('_SAUVER_CHEMIN', true);
1607 1606
 	}
1608 1607
 
1609
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1608
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1610 1609
 }
1611 1610
 
1612 1611
 function clear_path_cache() {
@@ -1675,12 +1674,12 @@  discard block
 block discarded – undo
1675 1674
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1676 1675
 	// on a pas encore inclus flock.php
1677 1676
 	if (!function_exists('preg_files')) {
1678
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1677
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1679 1678
 	}
1680 1679
 
1681 1680
 	// Parcourir le chemin
1682 1681
 	foreach (creer_chemin() as $d) {
1683
-		$f = $d . $dir;
1682
+		$f = $d.$dir;
1684 1683
 		if (@is_dir($f)) {
1685 1684
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1686 1685
 			foreach ($liste as $chemin) {
@@ -1710,9 +1709,9 @@  discard block
 block discarded – undo
1710 1709
 	static $autsanscookie = array('install', 'base_repair');
1711 1710
 
1712 1711
 	if (in_array($nom, $autsanscookie)) {
1713
-		if (test_espace_prive()){
1712
+		if (test_espace_prive()) {
1714 1713
 			include_spip('base/connect_sql');
1715
-			if (!$strict or !spip_connect()){
1714
+			if (!$strict or !spip_connect()) {
1716 1715
 				return true;
1717 1716
 			}
1718 1717
 		}
@@ -1791,7 +1790,7 @@  discard block
 block discarded – undo
1791 1790
 		return $res;
1792 1791
 	}
1793 1792
 	// Sinon c'est un raccourci ou compat SPIP < 2
1794
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1793
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1795 1794
 		if (!function_exists($f .= '_dist')) {
1796 1795
 			$f = '';
1797 1796
 		}
@@ -1800,8 +1799,8 @@  discard block
 block discarded – undo
1800 1799
 		$url = $f($id, $args, $ancre);
1801 1800
 		if (strlen($args)) {
1802 1801
 			$url .= strstr($url, '?')
1803
-				? '&amp;' . $args
1804
-				: '?' . $args;
1802
+				? '&amp;'.$args
1803
+				: '?'.$args;
1805 1804
 		}
1806 1805
 
1807 1806
 		return $url;
@@ -1832,8 +1831,8 @@  discard block
 block discarded – undo
1832 1831
 	include_spip('base/connect_sql');
1833 1832
 	$id_type = id_table_objet($entite, $public);
1834 1833
 
1835
-	return _DIR_RACINE . get_spip_script('./')
1836
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1834
+	return _DIR_RACINE.get_spip_script('./')
1835
+	. "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1837 1836
 	. (!$args ? '' : "&$args")
1838 1837
 	. (!$ancre ? '' : "#$ancre");
1839 1838
 }
@@ -1985,7 +1984,7 @@  discard block
 block discarded – undo
1985 1984
 			if (!empty($_SERVER['QUERY_STRING'])
1986 1985
 				and !strpos($_SERVER['REQUEST_URI'], '?')
1987 1986
 			) {
1988
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1987
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
1989 1988
 			}
1990 1989
 		}
1991 1990
 	}
@@ -2012,17 +2011,17 @@  discard block
 block discarded – undo
2012 2011
 	list($myself) = explode('?', $myself);
2013 2012
 	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2014 2013
 	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2015
-	if (strpos($myself,'://') !== false) {
2016
-		$myself = explode('://',$myself);
2014
+	if (strpos($myself, '://') !== false) {
2015
+		$myself = explode('://', $myself);
2017 2016
 		array_shift($myself);
2018
-		$myself = implode('://',$myself);
2019
-		$myself = explode('/',$myself);
2017
+		$myself = implode('://', $myself);
2018
+		$myself = explode('/', $myself);
2020 2019
 		array_shift($myself);
2021
-		$myself = implode('/',$myself);
2020
+		$myself = implode('/', $myself);
2022 2021
 	}
2023
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2022
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2024 2023
 
2025
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2024
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2026 2025
 
2027 2026
 	return $url;
2028 2027
 }
@@ -2060,17 +2059,17 @@  discard block
 block discarded – undo
2060 2059
  **/
2061 2060
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2062 2061
 	if (!$rel) {
2063
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2062
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2064 2063
 	} else {
2065 2064
 		if (!is_string($rel)) {
2066 2065
 			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2067
-				('./' . _SPIP_ECRIRE_SCRIPT);
2066
+				('./'._SPIP_ECRIRE_SCRIPT);
2068 2067
 		}
2069 2068
 	}
2070 2069
 
2071 2070
 	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2072 2071
 	if ($script and ($script <> 'accueil' or $rel)) {
2073
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2072
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2074 2073
 	} elseif ($args) {
2075 2074
 		$args = "?$args";
2076 2075
 	}
@@ -2078,7 +2077,7 @@  discard block
 block discarded – undo
2078 2077
 		$args .= "#$ancre";
2079 2078
 	}
2080 2079
 
2081
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2080
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2082 2081
 }
2083 2082
 
2084 2083
 //
@@ -2148,25 +2147,25 @@  discard block
 block discarded – undo
2148 2147
 		if (is_array($args)) {
2149 2148
 			$r = '';
2150 2149
 			foreach ($args as $k => $v) {
2151
-				$r .= '&' . $k . '=' . $v;
2150
+				$r .= '&'.$k.'='.$v;
2152 2151
 			}
2153 2152
 			$args = substr($r, 1);
2154 2153
 		}
2155 2154
 		$action .=
2156
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2155
+			(strpos($action, '?') !== false ? '&' : '?').$args;
2157 2156
 	}
2158 2157
 	if (!$no_entities) {
2159 2158
 		$action = quote_amp($action);
2160 2159
 	}
2161 2160
 
2162 2161
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2163
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2162
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action"));
2164 2163
 }
2165 2164
 
2166 2165
 // https://code.spip.net/@generer_url_prive
2167 2166
 function generer_url_prive($script, $args = "", $no_entities = false) {
2168 2167
 
2169
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2168
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2170 2169
 }
2171 2170
 
2172 2171
 // Pour les formulaires en methode POST,
@@ -2201,8 +2200,7 @@  discard block
 block discarded – undo
2201 2200
 	. "><div>\n"
2202 2201
 	. "<input type='hidden' name='exec' value='$script1' />"
2203 2202
 	. $corps
2204
-	. (!$submit ? '' :
2205
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2203
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>"))
2206 2204
 	. "</div></form>\n";
2207 2205
 }
2208 2206
 
@@ -2227,14 +2225,14 @@  discard block
 block discarded – undo
2227 2225
 		? generer_url_ecrire(_request('exec'))
2228 2226
 		: generer_url_public();
2229 2227
 
2230
-	return "\n<form action='" .
2231
-	$h .
2232
-	"'" .
2233
-	$atts .
2234
-	">\n" .
2235
-	"<div>" .
2236
-	"\n<input type='hidden' name='action' value='$script' />" .
2237
-	$corps .
2228
+	return "\n<form action='".
2229
+	$h.
2230
+	"'".
2231
+	$atts.
2232
+	">\n".
2233
+	"<div>".
2234
+	"\n<input type='hidden' name='action' value='$script' />".
2235
+	$corps.
2238 2236
 	"</div></form>";
2239 2237
 }
2240 2238
 
@@ -2262,7 +2260,7 @@  discard block
 block discarded – undo
2262 2260
 		: generer_url_public('', '', false, false);
2263 2261
 	$url = parametre_url($url, 'action', $script);
2264 2262
 	if ($args) {
2265
-		$url .= quote_amp('&' . $args);
2263
+		$url .= quote_amp('&'.$args);
2266 2264
 	}
2267 2265
 
2268 2266
 	if ($no_entities) {
@@ -2312,17 +2310,17 @@  discard block
 block discarded – undo
2312 2310
 
2313 2311
 	// le nom du repertoire plugins/ activables/desactivables
2314 2312
 	if (!defined('_DIR_PLUGINS')) {
2315
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2313
+		define('_DIR_PLUGINS', _DIR_RACINE."plugins/");
2316 2314
 	}
2317 2315
 
2318 2316
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2319 2317
 	if (!defined('_DIR_PLUGINS_DIST')) {
2320
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2318
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/");
2321 2319
 	}
2322 2320
 
2323 2321
 	// le nom du repertoire des librairies
2324 2322
 	if (!defined('_DIR_LIB')) {
2325
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2323
+		define('_DIR_LIB', _DIR_RACINE."lib/");
2326 2324
 	}
2327 2325
 
2328 2326
 	if (!defined('_DIR_IMG')) {
@@ -2332,29 +2330,29 @@  discard block
 block discarded – undo
2332 2330
 		define('_DIR_LOGOS', $pa);
2333 2331
 	}
2334 2332
 	if (!defined('_DIR_IMG_ICONES')) {
2335
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2333
+		define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/");
2336 2334
 	}
2337 2335
 
2338 2336
 	if (!defined('_DIR_DUMP')) {
2339
-		define('_DIR_DUMP', $ti . "dump/");
2337
+		define('_DIR_DUMP', $ti."dump/");
2340 2338
 	}
2341 2339
 	if (!defined('_DIR_SESSIONS')) {
2342
-		define('_DIR_SESSIONS', $ti . "sessions/");
2340
+		define('_DIR_SESSIONS', $ti."sessions/");
2343 2341
 	}
2344 2342
 	if (!defined('_DIR_TRANSFERT')) {
2345
-		define('_DIR_TRANSFERT', $ti . "upload/");
2343
+		define('_DIR_TRANSFERT', $ti."upload/");
2346 2344
 	}
2347 2345
 	if (!defined('_DIR_CACHE')) {
2348
-		define('_DIR_CACHE', $ti . "cache/");
2346
+		define('_DIR_CACHE', $ti."cache/");
2349 2347
 	}
2350 2348
 	if (!defined('_DIR_CACHE_XML')) {
2351
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2349
+		define('_DIR_CACHE_XML', _DIR_CACHE."xml/");
2352 2350
 	}
2353 2351
 	if (!defined('_DIR_SKELS')) {
2354
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2352
+		define('_DIR_SKELS', _DIR_CACHE."skel/");
2355 2353
 	}
2356 2354
 	if (!defined('_DIR_AIDE')) {
2357
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2355
+		define('_DIR_AIDE', _DIR_CACHE."aide/");
2358 2356
 	}
2359 2357
 	if (!defined('_DIR_TMP')) {
2360 2358
 		define('_DIR_TMP', $ti);
@@ -2384,27 +2382,27 @@  discard block
 block discarded – undo
2384 2382
 	// Declaration des fichiers
2385 2383
 
2386 2384
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2387
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2385
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php");
2388 2386
 	}
2389 2387
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2390
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2388
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php");
2391 2389
 	}
2392 2390
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2393
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2391
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php");
2394 2392
 	}
2395 2393
 	if (!defined('_CACHE_PIPELINES')) {
2396
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2394
+		define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php");
2397 2395
 	}
2398 2396
 	if (!defined('_CACHE_CHEMIN')) {
2399
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2397
+		define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt");
2400 2398
 	}
2401 2399
 
2402 2400
 	# attention .php obligatoire pour ecrire_fichier_securise
2403 2401
 	if (!defined('_FILE_META')) {
2404
-		define('_FILE_META', $ti . 'meta_cache.php');
2402
+		define('_FILE_META', $ti.'meta_cache.php');
2405 2403
 	}
2406 2404
 	if (!defined('_DIR_LOG')) {
2407
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2405
+		define('_DIR_LOG', _DIR_TMP.'log/');
2408 2406
 	}
2409 2407
 	if (!defined('_FILE_LOG')) {
2410 2408
 		define('_FILE_LOG', 'spip');
@@ -2420,8 +2418,8 @@  discard block
 block discarded – undo
2420 2418
 	}
2421 2419
 	if (!defined('_FILE_CONNECT')) {
2422 2420
 		define('_FILE_CONNECT',
2423
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2424
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2421
+		(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2422
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2425 2423
 				: false)));
2426 2424
 	}
2427 2425
 
@@ -2431,7 +2429,7 @@  discard block
 block discarded – undo
2431 2429
 	}
2432 2430
 	if (!defined('_FILE_CHMOD')) {
2433 2431
 		define('_FILE_CHMOD',
2434
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2432
+		(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2435 2433
 			: false));
2436 2434
 	}
2437 2435
 
@@ -2443,10 +2441,10 @@  discard block
 block discarded – undo
2443 2441
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2444 2442
 	}
2445 2443
 	if (!defined('_FILE_CONNECT_TMP')) {
2446
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2444
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2447 2445
 	}
2448 2446
 	if (!defined('_FILE_CHMOD_TMP')) {
2449
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2447
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2450 2448
 	}
2451 2449
 
2452 2450
 	// Definition des droits d'acces en ecriture
@@ -2464,13 +2462,13 @@  discard block
 block discarded – undo
2464 2462
 		define('_DEFAULT_CHARSET', 'utf-8');
2465 2463
 	}
2466 2464
 	if (!defined('_ROOT_PLUGINS')) {
2467
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2465
+		define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/");
2468 2466
 	}
2469 2467
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2470
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2468
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/");
2471 2469
 	}
2472 2470
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2473
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2471
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2474 2472
 	}
2475 2473
 
2476 2474
 	// La taille des Log
@@ -2507,7 +2505,7 @@  discard block
 block discarded – undo
2507 2505
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2508 2506
 	// pour le rendre surchargeable, on va provoquer un reecriture
2509 2507
 	// systematique du noyau ou une baisse de perfs => a etudier)
2510
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2508
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2511 2509
 
2512 2510
 	// charger tout de suite le path et son cache
2513 2511
 	load_path_cache();
@@ -2554,7 +2552,7 @@  discard block
 block discarded – undo
2554 2552
 		if (!empty($_SERVER['QUERY_STRING'])
2555 2553
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2556 2554
 		) {
2557
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2555
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2558 2556
 		}
2559 2557
 	}
2560 2558
 
@@ -2590,7 +2588,7 @@  discard block
 block discarded – undo
2590 2588
 
2591 2589
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2592 2590
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2593
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2591
+				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/';
2594 2592
 			} else {
2595 2593
 				$uri_ref = "";
2596 2594
 			}
@@ -2678,7 +2676,7 @@  discard block
 block discarded – undo
2678 2676
 	}
2679 2677
 	if (!defined('_CACHE_RUBRIQUES')) {
2680 2678
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2681
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2679
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2682 2680
 	}
2683 2681
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2684 2682
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -2770,7 +2768,7 @@  discard block
 block discarded – undo
2770 2768
 					$memory *= 1024;
2771 2769
 			}
2772 2770
 			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2773
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2771
+				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
2774 2772
 				if (trim(ini_get('memory_limit')) != $m) {
2775 2773
 					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2776 2774
 						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
@@ -2920,7 +2918,7 @@  discard block
 block discarded – undo
2920 2918
 					}
2921 2919
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
2922 2920
 						spip_log($GLOBALS['visiteur_session']['nom']
2923
-							. " " . _VAR_MODE);
2921
+							. " "._VAR_MODE);
2924 2922
 					}
2925 2923
 				} // pas autorise ?
2926 2924
 				else {
@@ -2928,7 +2926,7 @@  discard block
 block discarded – undo
2928 2926
 					if (!$GLOBALS['visiteur_session']) {
2929 2927
 						include_spip('inc/headers');
2930 2928
 						redirige_par_entete(generer_url_public('login',
2931
-							'url=' . rawurlencode(
2929
+							'url='.rawurlencode(
2932 2930
 								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2933 2931
 							), true));
2934 2932
 					}
@@ -2973,10 +2971,10 @@  discard block
 block discarded – undo
2973 2971
 	// mais on risque de perturber des plugins en initialisant trop tot
2974 2972
 	// certaines constantes
2975 2973
 	@spip_initialisation_core(
2976
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2977
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2978
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2979
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2974
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
2975
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
2976
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
2977
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
2980 2978
 	);
2981 2979
 
2982 2980
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3009,7 +3007,7 @@  discard block
 block discarded – undo
3009 3007
 	}
3010 3008
 
3011 3009
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3012
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3010
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3013 3011
 
3014 3012
 		$session = charger_fonction('session', 'inc');
3015 3013
 		if ($session()) {
@@ -3089,7 +3087,7 @@  discard block
 block discarded – undo
3089 3087
 		$s = pipeline('definir_session',
3090 3088
 			$GLOBALS['visiteur_session']
3091 3089
 				? serialize($GLOBALS['visiteur_session'])
3092
-				. '_' . @$_COOKIE['spip_session']
3090
+				. '_'.@$_COOKIE['spip_session']
3093 3091
 				: ''
3094 3092
 		);
3095 3093
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3245,12 +3243,12 @@  discard block
 block discarded – undo
3245 3243
 	$GLOBALS['_INC_PUBLIC']++;
3246 3244
 
3247 3245
 	// fix #4235
3248
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3246
+	$cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3249 3247
 
3250 3248
 
3251 3249
 	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3252 3250
 		
3253
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3251
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3254 3252
 
3255 3253
 		$page = evaluer_fond($f, $contexte, $connect);
3256 3254
 		if ($page === '') {
@@ -3289,7 +3287,7 @@  discard block
 block discarded – undo
3289 3287
 		}
3290 3288
 		
3291 3289
 		// contamination de la session appelante, pour les inclusions statiques
3292
-		if (isset($page['invalideurs']['session'])){
3290
+		if (isset($page['invalideurs']['session'])) {
3293 3291
 			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3294 3292
 		}
3295 3293
 	}
@@ -3335,7 +3333,7 @@  discard block
 block discarded – undo
3335 3333
  * @return array|string
3336 3334
  */
3337 3335
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3338
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3336
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3339 3337
 	if (!$pathinfo) {
3340 3338
 		return $f;
3341 3339
 	}
@@ -3556,7 +3554,7 @@  discard block
 block discarded – undo
3556 3554
 
3557 3555
 			if (!is_array($params[0])) {
3558 3556
 				trigger_error(
3559
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3557
+					'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
3560 3558
 					E_USER_WARNING
3561 3559
 				);
3562 3560
 				return null;
Please login to merge, or discard this patch.
ecrire/install/etape_3.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -248,6 +248,9 @@
 block discarded – undo
248 248
 
249 249
 
250 250
 // https://code.spip.net/@install_premier_auteur
251
+/**
252
+ * @param string $hidden
253
+ */
251 254
 function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) {
252 255
 	return info_progression_etape(3, 'etape_', 'install/') .
253 256
 	info_etape(
Please login to merge, or discard this patch.
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/headers');
@@ -20,199 +20,199 @@  discard block
 block discarded – undo
20 20
 // https://code.spip.net/@install_bases
21 21
 function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) {
22 22
 
23
-	// Prefix des tables :
24
-	// S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer
25
-	// a partir de ce qui est envoye a l'installation
26
-	if (!defined('_INSTALL_TABLE_PREFIX')) {
27
-		$table_prefix = ($GLOBALS['table_prefix'] != 'spip')
28
-			? $GLOBALS['table_prefix']
29
-			: preparer_prefixe_tables(_request('tprefix'));
30
-		// S'il est vide on remet spip
31
-		if (!$table_prefix) {
32
-			$table_prefix = 'spip';
33
-		}
34
-	} else {
35
-		$table_prefix = _INSTALL_TABLE_PREFIX;
36
-	}
37
-
38
-	if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
39
-		list(, $adresse_db, $port) = $r;
40
-	} else {
41
-		$port = '';
42
-	}
43
-
44
-	$GLOBALS['connexions'][$server_db]
45
-		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
46
-
47
-	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
48
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
49
-
50
-	$fquery = sql_serveur('query', $server_db);
51
-	if ($choix_db == 'new_spip') {
52
-		$re = ',^[a-z_][a-z_0-9-]*$,i';
53
-		if (preg_match($re, $sel_db)) {
54
-			$ok = sql_create_base($sel_db, $server_db);
55
-			if (!$ok) {
56
-				$re = "Impossible de creer la base $re";
57
-				spip_log($re);
58
-				return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
59
-			}
60
-		} else {
61
-			$re = "Le nom de la base doit correspondre a $re";
62
-			spip_log($re);
63
-
64
-			return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
65
-		}
66
-	}
67
-
68
-	// on rejoue la connexion apres avoir teste si il faut lui indiquer
69
-	// un sql_mode
70
-	install_mode_appel($server_db, false);
71
-	$GLOBALS['connexions'][$server_db]
72
-		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
73
-
74
-	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
75
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
76
-
77
-	// Completer le tableau decrivant la connexion
78
-
79
-	$GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
80
-	$GLOBALS['connexions'][$server_db]['db'] = $sel_db;
81
-
82
-	$old = sql_showbase($table_prefix . '_meta', $server_db);
83
-	if ($old) {
84
-		$old = sql_fetch($old, $server_db);
85
-	}
86
-	if (!$old) {
87
-		// Si possible, demander au serveur d'envoyer les textes
88
-		// dans le codage std de SPIP,
89
-		$charset = sql_get_charset(_DEFAULT_CHARSET, $server_db);
90
-
91
-		if ($charset) {
92
-			sql_set_charset($charset['charset'], $server_db);
93
-			$GLOBALS['meta']['charset_sql_base'] =
94
-				$charset['charset'];
95
-			$GLOBALS['meta']['charset_collation_sql_base'] =
96
-				$charset['collation'];
97
-			$GLOBALS['meta']['charset_sql_connexion'] =
98
-				$charset['charset'];
99
-			$charsetbase = $charset['charset'];
100
-		} else {
101
-			spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
102
-			$charsetbase = 'standard';
103
-		}
104
-		spip_log("Creation des tables. Codage $charsetbase");
105
-		creer_base($server_db); // AT LAST
106
-		// memoriser avec quel charset on l'a creee
107
-
108
-		if ($charset) {
109
-			$t = array(
110
-				'nom' => 'charset_sql_base',
111
-				'valeur' => $charset['charset'],
112
-				'impt' => 'non'
113
-			);
114
-			@sql_insertq('spip_meta', $t, '', $server_db);
115
-			$t['nom'] = 'charset_collation_sql_base';
116
-			$t['valeur'] = $charset['collation'];
117
-			@sql_insertq('spip_meta', $t, '', $server_db);
118
-			$t['nom'] = 'charset_sql_connexion';
119
-			$t['valeur'] = $charset['charset'];
120
-			@sql_insertq('spip_meta', $t, '', $server_db);
121
-		}
122
-		$t = array(
123
-			'nom' => 'version_installee',
124
-			'valeur' => $GLOBALS['spip_version_base'],
125
-			'impt' => 'non'
126
-		);
127
-		@sql_insertq('spip_meta', $t, '', $server_db);
128
-		$t['nom'] = 'nouvelle_install';
129
-		$t['valeur'] = 1;
130
-		@sql_insertq('spip_meta', $t, '', $server_db);
131
-		// positionner la langue par defaut du site si un cookie de lang a ete mis
132
-		if (isset($_COOKIE['spip_lang_ecrire'])) {
133
-			@sql_insertq(
134
-				'spip_meta',
135
-				array('nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']),
136
-				'',
137
-				$server_db
138
-			);
139
-		}
140
-	} else {
141
-		// pour recreer les tables disparues au besoin
142
-		spip_log('Table des Meta deja la. Verification des autres.');
143
-		creer_base($server_db);
144
-		$fupdateq = sql_serveur('updateq', $server_db);
145
-
146
-		$r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db);
147
-
148
-		if ($r) {
149
-			$r = sql_fetch($r, $server_db);
150
-		}
151
-		$version_installee = !$r ? 0 : (double)$r['valeur'];
152
-		if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
153
-			$fupdateq(
154
-				'spip_meta',
155
-				array('valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'),
156
-				"nom='version_installee'",
157
-				'',
158
-				$server_db
159
-			);
160
-			spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
161
-		}
162
-		// eliminer la derniere operation d'admin mal terminee
163
-		// notamment la mise a jour
164
-		@$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR  nom='admin'", $server_db);
165
-	}
166
-
167
-	// recuperer le charset de la connexion dans les meta
168
-	$charset = '';
169
-	$r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db);
170
-	if ($r) {
171
-		$r = sql_fetch($r, $server_db);
172
-	}
173
-	if ($r) {
174
-		$charset = $r['valeur'];
175
-	}
176
-
177
-	$ligne_rappel = install_mode_appel($server_db);
178
-
179
-	$result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db);
180
-	if (!$result_ok) {
181
-		return "<!--\nvielle = $old rappel= $ligne_rappel\n-->";
182
-	}
183
-
184
-	if ($chmod_db) {
185
-		install_fichier_connexion(
186
-			_FILE_CHMOD_TMP,
187
-			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
188
-		);
189
-	}
190
-
191
-	// si ce fichier existe a cette etape c'est qu'il provient
192
-	// d'une installation qui ne l'a pas cree correctement.
193
-	// Le supprimer pour que _FILE_CONNECT_TMP prime.
194
-
195
-	if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) {
196
-		spip_unlink(_FILE_CONNECT);
197
-	}
198
-
199
-	install_fichier_connexion(
200
-		_FILE_CONNECT_TMP,
201
-		$ligne_rappel
202
-		. install_connexion(
203
-			$adresse_db,
204
-			$port,
205
-			$login_db,
206
-			$pass_db,
207
-			$sel_db,
208
-			$server_db,
209
-			$table_prefix,
210
-			'',
211
-			$charset
212
-		)
213
-	);
214
-
215
-	return '';
23
+    // Prefix des tables :
24
+    // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer
25
+    // a partir de ce qui est envoye a l'installation
26
+    if (!defined('_INSTALL_TABLE_PREFIX')) {
27
+        $table_prefix = ($GLOBALS['table_prefix'] != 'spip')
28
+            ? $GLOBALS['table_prefix']
29
+            : preparer_prefixe_tables(_request('tprefix'));
30
+        // S'il est vide on remet spip
31
+        if (!$table_prefix) {
32
+            $table_prefix = 'spip';
33
+        }
34
+    } else {
35
+        $table_prefix = _INSTALL_TABLE_PREFIX;
36
+    }
37
+
38
+    if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
39
+        list(, $adresse_db, $port) = $r;
40
+    } else {
41
+        $port = '';
42
+    }
43
+
44
+    $GLOBALS['connexions'][$server_db]
45
+        = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
46
+
47
+    $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
48
+        = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
49
+
50
+    $fquery = sql_serveur('query', $server_db);
51
+    if ($choix_db == 'new_spip') {
52
+        $re = ',^[a-z_][a-z_0-9-]*$,i';
53
+        if (preg_match($re, $sel_db)) {
54
+            $ok = sql_create_base($sel_db, $server_db);
55
+            if (!$ok) {
56
+                $re = "Impossible de creer la base $re";
57
+                spip_log($re);
58
+                return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
59
+            }
60
+        } else {
61
+            $re = "Le nom de la base doit correspondre a $re";
62
+            spip_log($re);
63
+
64
+            return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
65
+        }
66
+    }
67
+
68
+    // on rejoue la connexion apres avoir teste si il faut lui indiquer
69
+    // un sql_mode
70
+    install_mode_appel($server_db, false);
71
+    $GLOBALS['connexions'][$server_db]
72
+        = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
73
+
74
+    $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
75
+        = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
76
+
77
+    // Completer le tableau decrivant la connexion
78
+
79
+    $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
80
+    $GLOBALS['connexions'][$server_db]['db'] = $sel_db;
81
+
82
+    $old = sql_showbase($table_prefix . '_meta', $server_db);
83
+    if ($old) {
84
+        $old = sql_fetch($old, $server_db);
85
+    }
86
+    if (!$old) {
87
+        // Si possible, demander au serveur d'envoyer les textes
88
+        // dans le codage std de SPIP,
89
+        $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db);
90
+
91
+        if ($charset) {
92
+            sql_set_charset($charset['charset'], $server_db);
93
+            $GLOBALS['meta']['charset_sql_base'] =
94
+                $charset['charset'];
95
+            $GLOBALS['meta']['charset_collation_sql_base'] =
96
+                $charset['collation'];
97
+            $GLOBALS['meta']['charset_sql_connexion'] =
98
+                $charset['charset'];
99
+            $charsetbase = $charset['charset'];
100
+        } else {
101
+            spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
102
+            $charsetbase = 'standard';
103
+        }
104
+        spip_log("Creation des tables. Codage $charsetbase");
105
+        creer_base($server_db); // AT LAST
106
+        // memoriser avec quel charset on l'a creee
107
+
108
+        if ($charset) {
109
+            $t = array(
110
+                'nom' => 'charset_sql_base',
111
+                'valeur' => $charset['charset'],
112
+                'impt' => 'non'
113
+            );
114
+            @sql_insertq('spip_meta', $t, '', $server_db);
115
+            $t['nom'] = 'charset_collation_sql_base';
116
+            $t['valeur'] = $charset['collation'];
117
+            @sql_insertq('spip_meta', $t, '', $server_db);
118
+            $t['nom'] = 'charset_sql_connexion';
119
+            $t['valeur'] = $charset['charset'];
120
+            @sql_insertq('spip_meta', $t, '', $server_db);
121
+        }
122
+        $t = array(
123
+            'nom' => 'version_installee',
124
+            'valeur' => $GLOBALS['spip_version_base'],
125
+            'impt' => 'non'
126
+        );
127
+        @sql_insertq('spip_meta', $t, '', $server_db);
128
+        $t['nom'] = 'nouvelle_install';
129
+        $t['valeur'] = 1;
130
+        @sql_insertq('spip_meta', $t, '', $server_db);
131
+        // positionner la langue par defaut du site si un cookie de lang a ete mis
132
+        if (isset($_COOKIE['spip_lang_ecrire'])) {
133
+            @sql_insertq(
134
+                'spip_meta',
135
+                array('nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']),
136
+                '',
137
+                $server_db
138
+            );
139
+        }
140
+    } else {
141
+        // pour recreer les tables disparues au besoin
142
+        spip_log('Table des Meta deja la. Verification des autres.');
143
+        creer_base($server_db);
144
+        $fupdateq = sql_serveur('updateq', $server_db);
145
+
146
+        $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db);
147
+
148
+        if ($r) {
149
+            $r = sql_fetch($r, $server_db);
150
+        }
151
+        $version_installee = !$r ? 0 : (double)$r['valeur'];
152
+        if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
153
+            $fupdateq(
154
+                'spip_meta',
155
+                array('valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'),
156
+                "nom='version_installee'",
157
+                '',
158
+                $server_db
159
+            );
160
+            spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
161
+        }
162
+        // eliminer la derniere operation d'admin mal terminee
163
+        // notamment la mise a jour
164
+        @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR  nom='admin'", $server_db);
165
+    }
166
+
167
+    // recuperer le charset de la connexion dans les meta
168
+    $charset = '';
169
+    $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db);
170
+    if ($r) {
171
+        $r = sql_fetch($r, $server_db);
172
+    }
173
+    if ($r) {
174
+        $charset = $r['valeur'];
175
+    }
176
+
177
+    $ligne_rappel = install_mode_appel($server_db);
178
+
179
+    $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db);
180
+    if (!$result_ok) {
181
+        return "<!--\nvielle = $old rappel= $ligne_rappel\n-->";
182
+    }
183
+
184
+    if ($chmod_db) {
185
+        install_fichier_connexion(
186
+            _FILE_CHMOD_TMP,
187
+            "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
188
+        );
189
+    }
190
+
191
+    // si ce fichier existe a cette etape c'est qu'il provient
192
+    // d'une installation qui ne l'a pas cree correctement.
193
+    // Le supprimer pour que _FILE_CONNECT_TMP prime.
194
+
195
+    if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) {
196
+        spip_unlink(_FILE_CONNECT);
197
+    }
198
+
199
+    install_fichier_connexion(
200
+        _FILE_CONNECT_TMP,
201
+        $ligne_rappel
202
+        . install_connexion(
203
+            $adresse_db,
204
+            $port,
205
+            $login_db,
206
+            $pass_db,
207
+            $sel_db,
208
+            $server_db,
209
+            $table_prefix,
210
+            '',
211
+            $charset
212
+        )
213
+    );
214
+
215
+    return '';
216 216
 }
217 217
 
218 218
 /**
@@ -227,169 +227,169 @@  discard block
 block discarded – undo
227 227
  * @return string Le préfixe corrigé
228 228
  */
229 229
 function preparer_prefixe_tables($prefixe) {
230
-	return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe))));
230
+    return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe))));
231 231
 }
232 232
 
233 233
 // https://code.spip.net/@install_propose_ldap
234 234
 function install_propose_ldap() {
235
-	return generer_form_ecrire('install', (
236
-	fieldset(
237
-		_T('info_authentification_externe'),
238
-		array(
239
-			'etape' => array(
240
-				'label' => _T('texte_annuaire_ldap_1'),
241
-				'valeur' => 'ldap1',
242
-				'hidden' => true
243
-			)
244
-		),
245
-		bouton_suivant(_T('bouton_acces_ldap'))
246
-	)));
235
+    return generer_form_ecrire('install', (
236
+    fieldset(
237
+        _T('info_authentification_externe'),
238
+        array(
239
+            'etape' => array(
240
+                'label' => _T('texte_annuaire_ldap_1'),
241
+                'valeur' => 'ldap1',
242
+                'hidden' => true
243
+            )
244
+        ),
245
+        bouton_suivant(_T('bouton_acces_ldap'))
246
+    )));
247 247
 }
248 248
 
249 249
 
250 250
 // https://code.spip.net/@install_premier_auteur
251 251
 function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) {
252
-	return info_progression_etape(3, 'etape_', 'install/') .
253
-	info_etape(
254
-		_T('info_informations_personnelles'),
255
-		'<b>' . _T('texte_informations_personnelles_1') . '</b>' .
256
-		aider('install5', true) .
257
-		'<p>' .
258
-		($auteur_obligatoire ?
259
-			''
260
-			:
261
-			_T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
262
-		)
263
-	)
264
-	. generer_form_ecrire('install', (
265
-		"\n<input type='hidden' name='etape' value='3b' />"
266
-		. $hidden
267
-		. fieldset(
268
-			_T('info_identification_publique'),
269
-			array(
270
-				'nom' => array(
271
-					'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
272
-					'valeur' => $nom,
273
-					'required' => $auteur_obligatoire,
274
-				),
275
-				'email' => array(
276
-					'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
277
-					'valeur' => $email,
278
-				)
279
-			)
280
-		)
281
-
282
-		. fieldset(
283
-			_T('entree_identifiants_connexion'),
284
-			array(
285
-				'login' => array(
286
-					'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
287
-						'info_login_trop_court_car_pluriel',
288
-						array('nb' => _LOGIN_TROP_COURT)
289
-					) . "\n",
290
-					'valeur' => $login,
291
-					'required' => $auteur_obligatoire,
292
-				),
293
-				'pass' => array(
294
-					'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
295
-						'info_passe_trop_court_car_pluriel',
296
-						array('nb' => _PASS_LONGUEUR_MINI)
297
-					) . "\n",
298
-					'valeur' => $pass,
299
-					'required' => $auteur_obligatoire,
300
-				),
301
-				'pass_verif' => array(
302
-					'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
303
-					'valeur' => $pass,
304
-					'required' => $auteur_obligatoire,
305
-				)
306
-			)
307
-		)
308
-		. bouton_suivant()));
252
+    return info_progression_etape(3, 'etape_', 'install/') .
253
+    info_etape(
254
+        _T('info_informations_personnelles'),
255
+        '<b>' . _T('texte_informations_personnelles_1') . '</b>' .
256
+        aider('install5', true) .
257
+        '<p>' .
258
+        ($auteur_obligatoire ?
259
+            ''
260
+            :
261
+            _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
262
+        )
263
+    )
264
+    . generer_form_ecrire('install', (
265
+        "\n<input type='hidden' name='etape' value='3b' />"
266
+        . $hidden
267
+        . fieldset(
268
+            _T('info_identification_publique'),
269
+            array(
270
+                'nom' => array(
271
+                    'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
272
+                    'valeur' => $nom,
273
+                    'required' => $auteur_obligatoire,
274
+                ),
275
+                'email' => array(
276
+                    'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
277
+                    'valeur' => $email,
278
+                )
279
+            )
280
+        )
281
+
282
+        . fieldset(
283
+            _T('entree_identifiants_connexion'),
284
+            array(
285
+                'login' => array(
286
+                    'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
287
+                        'info_login_trop_court_car_pluriel',
288
+                        array('nb' => _LOGIN_TROP_COURT)
289
+                    ) . "\n",
290
+                    'valeur' => $login,
291
+                    'required' => $auteur_obligatoire,
292
+                ),
293
+                'pass' => array(
294
+                    'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
295
+                        'info_passe_trop_court_car_pluriel',
296
+                        array('nb' => _PASS_LONGUEUR_MINI)
297
+                    ) . "\n",
298
+                    'valeur' => $pass,
299
+                    'required' => $auteur_obligatoire,
300
+                ),
301
+                'pass_verif' => array(
302
+                    'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
303
+                    'valeur' => $pass,
304
+                    'required' => $auteur_obligatoire,
305
+                )
306
+            )
307
+        )
308
+        . bouton_suivant()));
309 309
 }
310 310
 
311 311
 // https://code.spip.net/@install_etape_3_dist
312 312
 function install_etape_3_dist() {
313
-	$ldap_present = _request('ldap_present');
314
-
315
-	if (!$ldap_present) {
316
-		$adresse_db = defined('_INSTALL_HOST_DB')
317
-			? _INSTALL_HOST_DB
318
-			: _request('adresse_db');
319
-
320
-		$login_db = defined('_INSTALL_USER_DB')
321
-			? _INSTALL_USER_DB
322
-			: _request('login_db');
323
-
324
-		$pass_db = defined('_INSTALL_PASS_DB')
325
-			? _INSTALL_PASS_DB
326
-			: _request('pass_db');
327
-
328
-		$server_db = defined('_INSTALL_SERVER_DB')
329
-			? _INSTALL_SERVER_DB
330
-			: _request('server_db');
331
-
332
-		$chmod_db = defined('_SPIP_CHMOD')
333
-			? _SPIP_CHMOD
334
-			: _request('chmod');
335
-
336
-		$choix_db = defined('_INSTALL_NAME_DB')
337
-			? _INSTALL_NAME_DB
338
-			: _request('choix_db');
339
-
340
-		$sel_db = ($choix_db == 'new_spip')
341
-			? _request('table_new') : $choix_db;
342
-
343
-		$res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db);
344
-
345
-		if ($res) {
346
-			$res = info_progression_etape(2, 'etape_', 'install/', true)
347
-				. "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
348
-				. $res
349
-				. '<p>' . _T('texte_operation_echec') . '</p>'
350
-				. '</div>';
351
-		}
352
-	} else {
353
-		$res = '';
354
-		list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP);
355
-		$GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db);
356
-	}
357
-
358
-	if (!$res) {
359
-		if (file_exists(_FILE_CONNECT_TMP)) {
360
-			include(_FILE_CONNECT_TMP);
361
-		} else {
362
-			redirige_url_ecrire('install');
363
-		}
364
-
365
-		if (file_exists(_FILE_CHMOD_TMP)) {
366
-			include(_FILE_CHMOD_TMP);
367
-		} else {
368
-			redirige_url_ecrire('install');
369
-		}
370
-
371
-		$hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db)
372
-			. (defined('_INSTALL_NAME_DB') ? ''
373
-				: "\n<input type='hidden' name='sel_db' value='$sel_db' />");
374
-
375
-		$auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db));
376
-
377
-		$res = "<div class='success'><b>"
378
-			. _T('info_base_installee')
379
-			. '</b></div>'
380
-			. install_premier_auteur(
381
-				_request('email'),
382
-				_request('login'),
383
-				_request('nom'),
384
-				_request('pass'),
385
-				$hidden,
386
-				$auteur_obligatoire
387
-			)
388
-			. (($ldap_present or !function_exists('ldap_connect'))
389
-				? '' : install_propose_ldap());
390
-	}
391
-
392
-	echo install_debut_html();
393
-	echo $res;
394
-	echo install_fin_html();
313
+    $ldap_present = _request('ldap_present');
314
+
315
+    if (!$ldap_present) {
316
+        $adresse_db = defined('_INSTALL_HOST_DB')
317
+            ? _INSTALL_HOST_DB
318
+            : _request('adresse_db');
319
+
320
+        $login_db = defined('_INSTALL_USER_DB')
321
+            ? _INSTALL_USER_DB
322
+            : _request('login_db');
323
+
324
+        $pass_db = defined('_INSTALL_PASS_DB')
325
+            ? _INSTALL_PASS_DB
326
+            : _request('pass_db');
327
+
328
+        $server_db = defined('_INSTALL_SERVER_DB')
329
+            ? _INSTALL_SERVER_DB
330
+            : _request('server_db');
331
+
332
+        $chmod_db = defined('_SPIP_CHMOD')
333
+            ? _SPIP_CHMOD
334
+            : _request('chmod');
335
+
336
+        $choix_db = defined('_INSTALL_NAME_DB')
337
+            ? _INSTALL_NAME_DB
338
+            : _request('choix_db');
339
+
340
+        $sel_db = ($choix_db == 'new_spip')
341
+            ? _request('table_new') : $choix_db;
342
+
343
+        $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db);
344
+
345
+        if ($res) {
346
+            $res = info_progression_etape(2, 'etape_', 'install/', true)
347
+                . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
348
+                . $res
349
+                . '<p>' . _T('texte_operation_echec') . '</p>'
350
+                . '</div>';
351
+        }
352
+    } else {
353
+        $res = '';
354
+        list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP);
355
+        $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db);
356
+    }
357
+
358
+    if (!$res) {
359
+        if (file_exists(_FILE_CONNECT_TMP)) {
360
+            include(_FILE_CONNECT_TMP);
361
+        } else {
362
+            redirige_url_ecrire('install');
363
+        }
364
+
365
+        if (file_exists(_FILE_CHMOD_TMP)) {
366
+            include(_FILE_CHMOD_TMP);
367
+        } else {
368
+            redirige_url_ecrire('install');
369
+        }
370
+
371
+        $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db)
372
+            . (defined('_INSTALL_NAME_DB') ? ''
373
+                : "\n<input type='hidden' name='sel_db' value='$sel_db' />");
374
+
375
+        $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db));
376
+
377
+        $res = "<div class='success'><b>"
378
+            . _T('info_base_installee')
379
+            . '</b></div>'
380
+            . install_premier_auteur(
381
+                _request('email'),
382
+                _request('login'),
383
+                _request('nom'),
384
+                _request('pass'),
385
+                $hidden,
386
+                $auteur_obligatoire
387
+            )
388
+            . (($ldap_present or !function_exists('ldap_connect'))
389
+                ? '' : install_propose_ldap());
390
+    }
391
+
392
+    echo install_debut_html();
393
+    echo $res;
394
+    echo install_fin_html();
395 395
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
46 46
 
47 47
 	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
48
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
48
+		= $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']];
49 49
 
50 50
 	$fquery = sql_serveur('query', $server_db);
51 51
 	if ($choix_db == 'new_spip') {
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 			if (!$ok) {
56 56
 				$re = "Impossible de creer la base $re";
57 57
 				spip_log($re);
58
-				return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
58
+				return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->";
59 59
 			}
60 60
 		} else {
61 61
 			$re = "Le nom de la base doit correspondre a $re";
62 62
 			spip_log($re);
63 63
 
64
-			return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
64
+			return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->";
65 65
 		}
66 66
 	}
67 67
 
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
73 73
 
74 74
 	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
75
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
75
+		= $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']];
76 76
 
77 77
 	// Completer le tableau decrivant la connexion
78 78
 
79 79
 	$GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
80 80
 	$GLOBALS['connexions'][$server_db]['db'] = $sel_db;
81 81
 
82
-	$old = sql_showbase($table_prefix . '_meta', $server_db);
82
+	$old = sql_showbase($table_prefix.'_meta', $server_db);
83 83
 	if ($old) {
84 84
 		$old = sql_fetch($old, $server_db);
85 85
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				$charset['charset'];
99 99
 			$charsetbase = $charset['charset'];
100 100
 		} else {
101
-			spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
101
+			spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL');
102 102
 			$charsetbase = 'standard';
103 103
 		}
104 104
 		spip_log("Creation des tables. Codage $charsetbase");
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		if ($r) {
149 149
 			$r = sql_fetch($r, $server_db);
150 150
 		}
151
-		$version_installee = !$r ? 0 : (double)$r['valeur'];
151
+		$version_installee = !$r ? 0 : (double) $r['valeur'];
152 152
 		if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
153 153
 			$fupdateq(
154 154
 				'spip_meta',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				'',
158 158
 				$server_db
159 159
 			);
160
-			spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
160
+			spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']);
161 161
 		}
162 162
 		// eliminer la derniere operation d'admin mal terminee
163 163
 		// notamment la mise a jour
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($chmod_db) {
185 185
 		install_fichier_connexion(
186 186
 			_FILE_CHMOD_TMP,
187
-			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
187
+			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n"
188 188
 		);
189 189
 	}
190 190
 
@@ -249,16 +249,16 @@  discard block
 block discarded – undo
249 249
 
250 250
 // https://code.spip.net/@install_premier_auteur
251 251
 function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) {
252
-	return info_progression_etape(3, 'etape_', 'install/') .
252
+	return info_progression_etape(3, 'etape_', 'install/').
253 253
 	info_etape(
254 254
 		_T('info_informations_personnelles'),
255
-		'<b>' . _T('texte_informations_personnelles_1') . '</b>' .
256
-		aider('install5', true) .
257
-		'<p>' .
255
+		'<b>'._T('texte_informations_personnelles_1').'</b>'.
256
+		aider('install5', true).
257
+		'<p>'.
258 258
 		($auteur_obligatoire ?
259 259
 			''
260 260
 			:
261
-			_T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
261
+			_T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides')
262 262
 		)
263 263
 	)
264 264
 	. generer_form_ecrire('install', (
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 			_T('info_identification_publique'),
269 269
 			array(
270 270
 				'nom' => array(
271
-					'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
271
+					'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n",
272 272
 					'valeur' => $nom,
273 273
 					'required' => $auteur_obligatoire,
274 274
 				),
275 275
 				'email' => array(
276
-					'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
276
+					'label' => '<b>'._T('entree_adresse_email')."</b>\n",
277 277
 					'valeur' => $email,
278 278
 				)
279 279
 			)
@@ -283,23 +283,23 @@  discard block
 block discarded – undo
283 283
 			_T('entree_identifiants_connexion'),
284 284
 			array(
285 285
 				'login' => array(
286
-					'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
286
+					'label' => '<b>'._T('entree_login')."</b><br />\n"._T(
287 287
 						'info_login_trop_court_car_pluriel',
288 288
 						array('nb' => _LOGIN_TROP_COURT)
289
-					) . "\n",
289
+					)."\n",
290 290
 					'valeur' => $login,
291 291
 					'required' => $auteur_obligatoire,
292 292
 				),
293 293
 				'pass' => array(
294
-					'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
294
+					'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T(
295 295
 						'info_passe_trop_court_car_pluriel',
296 296
 						array('nb' => _PASS_LONGUEUR_MINI)
297
-					) . "\n",
297
+					)."\n",
298 298
 					'valeur' => $pass,
299 299
 					'required' => $auteur_obligatoire,
300 300
 				),
301 301
 				'pass_verif' => array(
302
-					'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
302
+					'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n",
303 303
 					'valeur' => $pass,
304 304
 					'required' => $auteur_obligatoire,
305 305
 				)
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 
345 345
 		if ($res) {
346 346
 			$res = info_progression_etape(2, 'etape_', 'install/', true)
347
-				. "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
347
+				. "<div class='error'><h3>"._T('avis_operation_echec').'</h3>'
348 348
 				. $res
349
-				. '<p>' . _T('texte_operation_echec') . '</p>'
349
+				. '<p>'._T('texte_operation_echec').'</p>'
350 350
 				. '</div>';
351 351
 		}
352 352
 	} else {
Please login to merge, or discard this patch.