Completed
Push — master ( 802cc1...846b27 )
by cam
01:24
created
ecrire/inc/selectionner.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/filtres');
@@ -46,56 +46,56 @@  discard block
 block discarded – undo
46 46
  **/
47 47
 function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
48 48
 
49
-	if ($recur) {
50
-		$recur = mini_hier($sel);
51
-	} else {
52
-		$sel = 0;
53
-	}
54
-
55
-	if ($aff_racine) {
56
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
-		$idom3 = $idom . '_selection';
58
-
59
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
60
-
61
-		$ondbClick = strtr(
62
-			str_replace(
63
-				"'",
64
-				'’',
65
-				str_replace(
66
-					'"',
67
-					'"',
68
-					textebrut(_T('info_racine_site'))
69
-				)
70
-			),
71
-			"\n\r",
72
-			'  '
73
-		);
74
-
75
-		$js_func = $do . '_selection_titre';
76
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
77
-
78
-		$aff_racine = "<div class='petit-item petite-racine item'>"
79
-			. "<a href='#'"
80
-			. 'onclick="'
81
-			. $onClick
82
-			. "\"\nondbclick=\""
83
-			. $ondbClick
84
-			. $onClick
85
-			. '">'
86
-			. _T('info_racine_site')
87
-			. '</a></div>';
88
-	}
89
-
90
-	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
91
-
92
-	$plonger = charger_fonction('plonger', 'inc');
93
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
94
-
95
-	// url completee par la fonction JS onkeypress_rechercher
96
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
97
-
98
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
49
+    if ($recur) {
50
+        $recur = mini_hier($sel);
51
+    } else {
52
+        $sel = 0;
53
+    }
54
+
55
+    if ($aff_racine) {
56
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
+        $idom3 = $idom . '_selection';
58
+
59
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
60
+
61
+        $ondbClick = strtr(
62
+            str_replace(
63
+                "'",
64
+                '&#8217;',
65
+                str_replace(
66
+                    '"',
67
+                    '&#34;',
68
+                    textebrut(_T('info_racine_site'))
69
+                )
70
+            ),
71
+            "\n\r",
72
+            '  '
73
+        );
74
+
75
+        $js_func = $do . '_selection_titre';
76
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
77
+
78
+        $aff_racine = "<div class='petit-item petite-racine item'>"
79
+            . "<a href='#'"
80
+            . 'onclick="'
81
+            . $onClick
82
+            . "\"\nondbclick=\""
83
+            . $ondbClick
84
+            . $onClick
85
+            . '">'
86
+            . _T('info_racine_site')
87
+            . '</a></div>';
88
+    }
89
+
90
+    $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
91
+
92
+    $plonger = charger_fonction('plonger', 'inc');
93
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
94
+
95
+    // url completee par la fonction JS onkeypress_rechercher
96
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
97
+
98
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
99 99
 }
100 100
 
101 101
 /**
@@ -113,58 +113,58 @@  discard block
 block discarded – undo
113 113
  **/
114 114
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
115 115
 
116
-	$idom1 = $idom . '_champ_recherche';
117
-	$idom2 = $idom . '_principal';
118
-	$idom3 = $idom . '_selection';
119
-	$idom4 = $idom . '_col_1';
120
-	$idom5 = 'img_' . $idom4;
121
-	$idom6 = $idom . '_fonc';
122
-
123
-	return "<div id='$idom'>"
124
-	. "<a id='$idom6' style='visibility: hidden;'"
125
-	. ($url_init ? "\nhref='$url_init'" : '')
126
-	. '></a>'
127
-	. "<div class='recherche_rapide_parent formulaire_recherche'>"
128
-	. http_img_pack(
129
-		'loader.svg',
130
-		'',
131
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
132
-	)
133
-	. ''
134
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
135
-	// eliminer Return car il provoque la soumission (balise unique)
136
-	// et eliminer Tab pour la navigation au clavier
137
-	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
138
-	// resultats retournes par la recherche
139
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
140
-	// lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
141
-	. "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
142
-	// la destination de la recherche
143
-	. "'$idom4'"
116
+    $idom1 = $idom . '_champ_recherche';
117
+    $idom2 = $idom . '_principal';
118
+    $idom3 = $idom . '_selection';
119
+    $idom4 = $idom . '_col_1';
120
+    $idom5 = 'img_' . $idom4;
121
+    $idom6 = $idom . '_fonc';
122
+
123
+    return "<div id='$idom'>"
124
+    . "<a id='$idom6' style='visibility: hidden;'"
125
+    . ($url_init ? "\nhref='$url_init'" : '')
126
+    . '></a>'
127
+    . "<div class='recherche_rapide_parent formulaire_recherche'>"
128
+    . http_img_pack(
129
+        'loader.svg',
130
+        '',
131
+        "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
132
+    )
133
+    . ''
134
+    . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
135
+    // eliminer Return car il provoque la soumission (balise unique)
136
+    // et eliminer Tab pour la navigation au clavier
137
+    // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
138
+    // resultats retournes par la recherche
139
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
140
+    // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
141
+    . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
142
+    // la destination de la recherche
143
+    . "'$idom4'"
144 144
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
145
-	. ",'"
146
-	// l'url effectuant la recherche
147
-	. $url
148
-	. "',"
149
-	// le noeud contenant un gif anime
150
-	// . "'idom5'"
151
-	. 'this.parentNode.previousSibling.firstChild'
152
-	. ",'"
153
-	// la valeur de l'attribut Name a remplir
154
-	. $name
155
-	. "','"
156
-	// noeud invisible memorisant l'URL initiale (pour re-initialisation)
157
-	. $idom6
158
-	. "')\""
159
-	. ' />'
160
-	. "\n</div>"
161
-	. ($racine ? "<div>$racine</div>" : '')
162
-	. "<div id='"
163
-	. $idom2
164
-	. "'><div id='$idom4'"
165
-	. " class=''>"
166
-	. $liste
167
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
145
+    . ",'"
146
+    // l'url effectuant la recherche
147
+    . $url
148
+    . "',"
149
+    // le noeud contenant un gif anime
150
+    // . "'idom5'"
151
+    . 'this.parentNode.previousSibling.firstChild'
152
+    . ",'"
153
+    // la valeur de l'attribut Name a remplir
154
+    . $name
155
+    . "','"
156
+    // noeud invisible memorisant l'URL initiale (pour re-initialisation)
157
+    . $idom6
158
+    . "')\""
159
+    . ' />'
160
+    . "\n</div>"
161
+    . ($racine ? "<div>$racine</div>" : '')
162
+    . "<div id='"
163
+    . $idom2
164
+    . "'><div id='$idom4'"
165
+    . " class=''>"
166
+    . $liste
167
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
168 168
 }
169 169
 
170 170
 /**
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
  **/
177 177
 function mini_hier($id_rubrique) {
178 178
 
179
-	$liste = $id_rubrique;
180
-	$id_rubrique = intval($id_rubrique);
181
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
182
-		$liste = $id_rubrique . ",$liste";
183
-	}
179
+    $liste = $id_rubrique;
180
+    $id_rubrique = intval($id_rubrique);
181
+    while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
182
+        $liste = $id_rubrique . ",$liste";
183
+    }
184 184
 
185
-	return explode(',', "0,$liste");
185
+    return explode(',', "0,$liste");
186 186
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	if ($aff_racine) {
56 56
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
-		$idom3 = $idom . '_selection';
57
+		$idom3 = $idom.'_selection';
58 58
 
59 59
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
60 60
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			'  '
73 73
 		);
74 74
 
75
-		$js_func = $do . '_selection_titre';
75
+		$js_func = $do.'_selection_titre';
76 76
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
77 77
 
78 78
 		$aff_racine = "<div class='petit-item petite-racine item'>"
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
  **/
114 114
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
115 115
 
116
-	$idom1 = $idom . '_champ_recherche';
117
-	$idom2 = $idom . '_principal';
118
-	$idom3 = $idom . '_selection';
119
-	$idom4 = $idom . '_col_1';
120
-	$idom5 = 'img_' . $idom4;
121
-	$idom6 = $idom . '_fonc';
116
+	$idom1 = $idom.'_champ_recherche';
117
+	$idom2 = $idom.'_principal';
118
+	$idom3 = $idom.'_selection';
119
+	$idom4 = $idom.'_col_1';
120
+	$idom5 = 'img_'.$idom4;
121
+	$idom6 = $idom.'_fonc';
122 122
 
123 123
 	return "<div id='$idom'>"
124 124
 	. "<a id='$idom6' style='visibility: hidden;'"
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	. http_img_pack(
129 129
 		'loader.svg',
130 130
 		'',
131
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
+		"class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'"
132 132
 	)
133 133
 	. ''
134
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
+	. "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'"
135 135
 	// eliminer Return car il provoque la soumission (balise unique)
136 136
 	// et eliminer Tab pour la navigation au clavier
137 137
 	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 
179 179
 	$liste = $id_rubrique;
180 180
 	$id_rubrique = intval($id_rubrique);
181
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
182
-		$liste = $id_rubrique . ",$liste";
181
+	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) {
182
+		$liste = $id_rubrique.",$liste";
183 183
 	}
184 184
 
185 185
 	return explode(',', "0,$liste");
Please login to merge, or discard this patch.
ecrire/inc/notifications.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 	if ($notification = charger_fonction($quoi, 'notifications', true)) {
41 41
 		spip_log("$notification($quoi,$id"
42
-			. ($options ? ',' . serialize($options) : '')
42
+			. ($options ? ','.serialize($options) : '')
43 43
 			. ')', 'notifications');
44 44
 		$notification($quoi, $id, $options);
45 45
 	}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		job_queue_add(
159 159
 			'envoyer_mail',
160
-			">$email : " . $envoi['sujet'],
160
+			">$email : ".$envoi['sujet'],
161 161
 			[$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']],
162 162
 			'inc/'
163 163
 		);
Please login to merge, or discard this patch.
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Notifications
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function inc_notifications_dist($quoi, $id = 0, $options = []) {
35 35
 
36
-	// charger les fichiers qui veulent ajouter des definitions
37
-	// ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ...
38
-	pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]);
36
+    // charger les fichiers qui veulent ajouter des definitions
37
+    // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ...
38
+    pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]);
39 39
 
40
-	if ($notification = charger_fonction($quoi, 'notifications', true)) {
41
-		spip_log("$notification($quoi,$id"
42
-			. ($options ? ',' . serialize($options) : '')
43
-			. ')', 'notifications');
44
-		$notification($quoi, $id, $options);
45
-	}
40
+    if ($notification = charger_fonction($quoi, 'notifications', true)) {
41
+        spip_log("$notification($quoi,$id"
42
+            . ($options ? ',' . serialize($options) : '')
43
+            . ')', 'notifications');
44
+        $notification($quoi, $id, $options);
45
+    }
46 46
 }
47 47
 
48 48
 /**
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
  * @param array $exclure
57 57
  */
58 58
 function notifications_nettoyer_emails(&$emails, $exclure = []) {
59
-	// filtrer et unifier
60
-	include_spip('inc/filtres');
61
-	$emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails))));
62
-	if ($exclure and count($exclure)) {
63
-		// nettoyer les exclusions d'abord
64
-		notifications_nettoyer_emails($exclure);
65
-		// faire un diff
66
-		$emails = array_diff($emails, $exclure);
67
-	}
59
+    // filtrer et unifier
60
+    include_spip('inc/filtres');
61
+    $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails))));
62
+    if ($exclure and count($exclure)) {
63
+        // nettoyer les exclusions d'abord
64
+        notifications_nettoyer_emails($exclure);
65
+        // faire un diff
66
+        $emails = array_diff($emails, $exclure);
67
+    }
68 68
 }
69 69
 
70 70
 /**
@@ -79,90 +79,90 @@  discard block
 block discarded – undo
79 79
  * @param string $headers
80 80
  */
81 81
 function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') {
82
-	// rien a faire si pas de texte !
83
-	if (!strlen($texte)) {
84
-		return;
85
-	}
86
-
87
-	// si on ne specifie qu'un email, le mettre dans un tableau
88
-	if (!is_array($emails)) {
89
-		$emails = explode(',', $emails);
90
-	}
91
-
92
-	notifications_nettoyer_emails($emails);
93
-
94
-	// tester si le mail est deja en html
95
-	if (
96
-		strpos($texte, '<') !== false // eviter les tests suivants si possible
97
-		and $ttrim = trim($texte)
98
-		and substr($ttrim, 0, 1) == '<'
99
-		and substr($ttrim, -1, 1) == '>'
100
-		and stripos($ttrim, '</html>') !== false
101
-	) {
102
-		if (!strlen($sujet)) {
103
-			// dans ce cas on ruse un peu : extraire le sujet du title
104
-			if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) {
105
-				$sujet = $m[1];
106
-			} else {
107
-				// fallback, on prend le body si on le trouve
108
-				if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) {
109
-					$ttrim = $m[1];
110
-				}
111
-
112
-				// et on extrait la premiere ligne de vrai texte...
113
-				// nettoyer le html et les retours chariots
114
-				$ttrim = textebrut($ttrim);
115
-				$ttrim = str_replace("\r\n", "\r", $ttrim);
116
-				$ttrim = str_replace("\r", "\n", $ttrim);
117
-				// decouper
118
-				$ttrim = explode("\n", trim($ttrim));
119
-				// extraire la premiere ligne de texte brut
120
-				$sujet = array_shift($ttrim);
121
-			}
122
-		}
123
-
124
-		// si besoin on ajoute le content-type dans les headers
125
-		if (stripos($headers, 'Content-Type') === false) {
126
-			$headers .= "Content-Type: text/html\n";
127
-		}
128
-	}
129
-
130
-	// si le sujet est vide, extraire la premiere ligne du corps
131
-	// du mail qui est donc du texte
132
-	if (!strlen($sujet)) {
133
-		// nettoyer un peu les retours chariots
134
-		$texte = str_replace("\r\n", "\r", $texte);
135
-		$texte = str_replace("\r", "\n", $texte);
136
-		// decouper
137
-		$texte = explode("\n", trim($texte));
138
-		// extraire la premiere ligne
139
-		$sujet = array_shift($texte);
140
-		$texte = trim(implode("\n", $texte));
141
-	}
142
-
143
-	$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
144
-	foreach ($emails as $email) {
145
-		// passer dans un pipeline qui permet un ajout eventuel
146
-		// (url de suivi des notifications par exemple)
147
-		$envoi = pipeline(
148
-			'notifications_envoyer_mails',
149
-			[
150
-				'email' => $email,
151
-				'sujet' => $sujet,
152
-				'texte' => $texte,
153
-				'from' => $from,
154
-				'headers' => $headers,
155
-			]
156
-		);
157
-		$email = $envoi['email'];
158
-
159
-		job_queue_add(
160
-			'envoyer_mail',
161
-			">$email : " . $envoi['sujet'],
162
-			[$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']],
163
-			'inc/'
164
-		);
165
-	}
82
+    // rien a faire si pas de texte !
83
+    if (!strlen($texte)) {
84
+        return;
85
+    }
86
+
87
+    // si on ne specifie qu'un email, le mettre dans un tableau
88
+    if (!is_array($emails)) {
89
+        $emails = explode(',', $emails);
90
+    }
91
+
92
+    notifications_nettoyer_emails($emails);
93
+
94
+    // tester si le mail est deja en html
95
+    if (
96
+        strpos($texte, '<') !== false // eviter les tests suivants si possible
97
+        and $ttrim = trim($texte)
98
+        and substr($ttrim, 0, 1) == '<'
99
+        and substr($ttrim, -1, 1) == '>'
100
+        and stripos($ttrim, '</html>') !== false
101
+    ) {
102
+        if (!strlen($sujet)) {
103
+            // dans ce cas on ruse un peu : extraire le sujet du title
104
+            if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) {
105
+                $sujet = $m[1];
106
+            } else {
107
+                // fallback, on prend le body si on le trouve
108
+                if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) {
109
+                    $ttrim = $m[1];
110
+                }
111
+
112
+                // et on extrait la premiere ligne de vrai texte...
113
+                // nettoyer le html et les retours chariots
114
+                $ttrim = textebrut($ttrim);
115
+                $ttrim = str_replace("\r\n", "\r", $ttrim);
116
+                $ttrim = str_replace("\r", "\n", $ttrim);
117
+                // decouper
118
+                $ttrim = explode("\n", trim($ttrim));
119
+                // extraire la premiere ligne de texte brut
120
+                $sujet = array_shift($ttrim);
121
+            }
122
+        }
123
+
124
+        // si besoin on ajoute le content-type dans les headers
125
+        if (stripos($headers, 'Content-Type') === false) {
126
+            $headers .= "Content-Type: text/html\n";
127
+        }
128
+    }
129
+
130
+    // si le sujet est vide, extraire la premiere ligne du corps
131
+    // du mail qui est donc du texte
132
+    if (!strlen($sujet)) {
133
+        // nettoyer un peu les retours chariots
134
+        $texte = str_replace("\r\n", "\r", $texte);
135
+        $texte = str_replace("\r", "\n", $texte);
136
+        // decouper
137
+        $texte = explode("\n", trim($texte));
138
+        // extraire la premiere ligne
139
+        $sujet = array_shift($texte);
140
+        $texte = trim(implode("\n", $texte));
141
+    }
142
+
143
+    $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
144
+    foreach ($emails as $email) {
145
+        // passer dans un pipeline qui permet un ajout eventuel
146
+        // (url de suivi des notifications par exemple)
147
+        $envoi = pipeline(
148
+            'notifications_envoyer_mails',
149
+            [
150
+                'email' => $email,
151
+                'sujet' => $sujet,
152
+                'texte' => $texte,
153
+                'from' => $from,
154
+                'headers' => $headers,
155
+            ]
156
+        );
157
+        $email = $envoi['email'];
158
+
159
+        job_queue_add(
160
+            'envoyer_mail',
161
+            ">$email : " . $envoi['sujet'],
162
+            [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']],
163
+            'inc/'
164
+        );
165
+    }
166 166
 }
167 167
 
168 168
 /**
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
  * @return string
179 179
  */
180 180
 function email_notification_objet($id_objet, $type_objet, $modele) {
181
-	$envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
182
-	$id_type = id_table_objet($type_objet);
181
+    $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
182
+    $id_type = id_table_objet($type_objet);
183 183
 
184
-	return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]);
184
+    return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]);
185 185
 }
186 186
 
187 187
 /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  * @return string
197 197
  */
198 198
 function email_notification_article($id_article, $modele) {
199
-	$envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
199
+    $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
200 200
 
201
-	return recuperer_fond($modele, ['id_article' => $id_article]);
201
+    return recuperer_fond($modele, ['id_article' => $id_article]);
202 202
 }
Please login to merge, or discard this patch.
ecrire/inc/email_valide.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Mail
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
  *      - la normalisation de la dernière adresse donnée sinon
32 32
  **/
33 33
 function inc_email_valide_dist($adresses) {
34
-	// eviter d'injecter n'importe quoi dans preg_match
35
-	if (!is_string($adresses)) {
36
-		return false;
37
-	}
38
-
39
-	// Si c'est un spammeur autant arreter tout de suite
40
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
41
-		spip_log("Tentative d'injection de mail : $adresses");
42
-
43
-		return false;
44
-	}
45
-
46
-	foreach (explode(',', $adresses) as $v) {
47
-		// nettoyer certains formats
48
-		// "Marie Toto <[email protected]>"
49
-		$adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v));
50
-		// RFC 822
51
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
52
-			return false;
53
-		}
54
-	}
55
-
56
-	return $adresse;
34
+    // eviter d'injecter n'importe quoi dans preg_match
35
+    if (!is_string($adresses)) {
36
+        return false;
37
+    }
38
+
39
+    // Si c'est un spammeur autant arreter tout de suite
40
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
41
+        spip_log("Tentative d'injection de mail : $adresses");
42
+
43
+        return false;
44
+    }
45
+
46
+    foreach (explode(',', $adresses) as $v) {
47
+        // nettoyer certains formats
48
+        // "Marie Toto <[email protected]>"
49
+        $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v));
50
+        // RFC 822
51
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
52
+            return false;
53
+        }
54
+    }
55
+
56
+    return $adresse;
57 57
 }
Please login to merge, or discard this patch.
ecrire/inc/chercher_logo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	$mode = preg_replace(',\W,', '', $mode);
41 41
 	if ($mode) {
42 42
 		// chercher dans la base
43
-		$mode_document = 'logo' . $mode;
43
+		$mode_document = 'logo'.$mode;
44 44
 		$objet = objet_type($_id_objet);
45
-		$doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id));
45
+		$doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode='.sql_quote($mode_document).' AND L.objet='.sql_quote($objet).' AND id_objet='.intval($id));
46 46
 		if ($doc) {
47 47
 			include_spip('inc/documents');
48 48
 			$d = get_spip_doc($doc['fichier']);
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 		if ($compat_old_logos) {
54 54
 			# attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
55 55
 			$type = type_du_logo($_id_objet);
56
-			$nom = $type . $mode . intval($id);
56
+			$nom = $type.$mode.intval($id);
57 57
 
58 58
 			foreach ($GLOBALS['formats_logos'] as $format) {
59
-				if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
59
+				if (@file_exists($d = (_DIR_LOGOS.$nom.'.'.$format))) {
60 60
 					return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)];
61 61
 				}
62 62
 			}
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Logos
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
  **/
38 38
 function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on', $compat_old_logos = true) {
39 39
 
40
-	$mode = preg_replace(',\W,', '', $mode);
41
-	if ($mode) {
42
-		// chercher dans la base
43
-		$mode_document = 'logo' . $mode;
44
-		$objet = objet_type($_id_objet);
45
-		$doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id));
46
-		if ($doc) {
47
-			include_spip('inc/documents');
48
-			$d = get_spip_doc($doc['fichier']);
49
-			return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc];
50
-		}
40
+    $mode = preg_replace(',\W,', '', $mode);
41
+    if ($mode) {
42
+        // chercher dans la base
43
+        $mode_document = 'logo' . $mode;
44
+        $objet = objet_type($_id_objet);
45
+        $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id));
46
+        if ($doc) {
47
+            include_spip('inc/documents');
48
+            $d = get_spip_doc($doc['fichier']);
49
+            return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc];
50
+        }
51 51
 
52
-		# deprecated TODO remove
53
-		if ($compat_old_logos) {
54
-			# attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
55
-			$type = type_du_logo($_id_objet);
56
-			$nom = $type . $mode . intval($id);
52
+        # deprecated TODO remove
53
+        if ($compat_old_logos) {
54
+            # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
55
+            $type = type_du_logo($_id_objet);
56
+            $nom = $type . $mode . intval($id);
57 57
 
58
-			foreach ($GLOBALS['formats_logos'] as $format) {
59
-				if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
60
-					return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)];
61
-				}
62
-			}
63
-		}
64
-	}
58
+            foreach ($GLOBALS['formats_logos'] as $format) {
59
+                if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
60
+                    return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)];
61
+                }
62
+            }
63
+        }
64
+    }
65 65
 
66
-	# coherence de type pour servir comme filtre (formulaire_login)
67
-	return [];
66
+    # coherence de type pour servir comme filtre (formulaire_login)
67
+    return [];
68 68
 }
69 69
 
70 70
 /**
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
  * @deprecated 4.0 MAIS NE PAS SUPPRIMER CAR SERT POUR L'UPGRADE des logos et leur mise en base
84 84
  **/
85 85
 function type_du_logo($_id_objet) {
86
-	return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet));
86
+    return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet));
87 87
 }
88 88
 
89 89
 // Exceptions standards (historique)
90 90
 $GLOBALS['table_logos'] = [
91
-	'id_article' => 'art',
92
-	'id_auteur' => 'aut',
93
-	'id_rubrique' => 'rub',
94
-	'id_groupe' => 'groupe',
91
+    'id_article' => 'art',
92
+    'id_auteur' => 'aut',
93
+    'id_rubrique' => 'rub',
94
+    'id_groupe' => 'groupe',
95 95
 ];
Please login to merge, or discard this patch.
ecrire/inc/completer_traduction.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -29,51 +29,51 @@  discard block
 block discarded – undo
29 29
  * @return string Erreur éventuelle
30 30
  */
31 31
 function inc_completer_traduction_dist($objet, $id_objet, $id_trad) {
32
-	// dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
33
-	// cf API editer_liens
34
-	include_spip('action/editer_liens');
35
-	objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
36
-	$_id_table = id_table_objet($objet);
32
+    // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
33
+    // cf API editer_liens
34
+    include_spip('action/editer_liens');
35
+    objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
36
+    $_id_table = id_table_objet($objet);
37 37
 
38
-	// recuperer le logo
39
-	$chercher_logo = charger_fonction('chercher_logo', 'inc');
40
-	include_spip('action/editer_logo');
41
-	foreach (['on', 'off'] as $etat) {
42
-		$logo = $chercher_logo($id_trad, $_id_table, $etat);
43
-		if ($logo and $file = reset($logo)) {
44
-			logo_modifier($objet, $id_objet, $etat, $file);
45
-		}
46
-	}
38
+    // recuperer le logo
39
+    $chercher_logo = charger_fonction('chercher_logo', 'inc');
40
+    include_spip('action/editer_logo');
41
+    foreach (['on', 'off'] as $etat) {
42
+        $logo = $chercher_logo($id_trad, $_id_table, $etat);
43
+        if ($logo and $file = reset($logo)) {
44
+            logo_modifier($objet, $id_objet, $etat, $file);
45
+        }
46
+    }
47 47
 
48
-	// dupliquer certains champs
49
-	$trouver_table = charger_fonction('trouver_table', 'base');
50
-	$desc = $trouver_table(table_objet_sql($objet));
51
-	$champs = $set = [];
48
+    // dupliquer certains champs
49
+    $trouver_table = charger_fonction('trouver_table', 'base');
50
+    $desc = $trouver_table(table_objet_sql($objet));
51
+    $champs = $set = [];
52 52
 
53
-	// un éventuel champ 'virtuel' (redirections)
54
-	if (!empty($desc['field']['virtuel'])) {
55
-		$champs[] = 'virtuel';
56
-	}
53
+    // un éventuel champ 'virtuel' (redirections)
54
+    if (!empty($desc['field']['virtuel'])) {
55
+        $champs[] = 'virtuel';
56
+    }
57 57
 
58
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad));
58
+    $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad));
59 59
 
60
-	foreach ($champs as $c) {
61
-		$set[$c] = $data[$c];
62
-	}
60
+    foreach ($champs as $c) {
61
+        $set[$c] = $data[$c];
62
+    }
63 63
 
64
-	/*
64
+    /*
65 65
 	 * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'.
66 66
 	 * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction.
67 67
 	 */
68
-	$err = objet_modifier_champs(
69
-		$objet,
70
-		$id_objet,
71
-		[
72
-			'data' => $data,
73
-			'action' => 'completer_traduction',
74
-		],
75
-		$set
76
-	);
68
+    $err = objet_modifier_champs(
69
+        $objet,
70
+        $id_objet,
71
+        [
72
+            'data' => $data,
73
+            'action' => 'completer_traduction',
74
+        ],
75
+        $set
76
+    );
77 77
 
78
-	return $err;
78
+    return $err;
79 79
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		$champs[] = 'virtuel';
56 56
 	}
57 57
 
58
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad));
58
+	$data = sql_fetsel('*', $desc['table'], $_id_table.'='.intval($id_trad));
59 59
 
60 60
 	foreach ($champs as $c) {
61 61
 		$set[$c] = $data[$c];
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function autosave_clean_value($val) {
30
-	return stripslashes(urldecode($val));
30
+    return stripslashes(urldecode($val));
31 31
 }
32 32
 
33 33
 /**
@@ -38,58 +38,58 @@  discard block
 block discarded – undo
38 38
  * @return array
39 39
  */
40 40
 function cvtautosave_formulaire_charger($flux) {
41
-	if (
42
-		is_array($flux['data'])
43
-		and isset($flux['data']['_autosave_id'])
44
-		and $cle_autosave = $flux['data']['_autosave_id']
45
-	) {
46
-		$form = $flux['args']['form'];
47
-		$je_suis_poste = $flux['args']['je_suis_poste'];
41
+    if (
42
+        is_array($flux['data'])
43
+        and isset($flux['data']['_autosave_id'])
44
+        and $cle_autosave = $flux['data']['_autosave_id']
45
+    ) {
46
+        $form = $flux['args']['form'];
47
+        $je_suis_poste = $flux['args']['je_suis_poste'];
48 48
 
49
-		$cle_autosave = serialize($cle_autosave);
50
-		$cle_autosave = $form . '_' . md5($cle_autosave);
49
+        $cle_autosave = serialize($cle_autosave);
50
+        $cle_autosave = $form . '_' . md5($cle_autosave);
51 51
 
52
-		// si on a un backup en session et qu'on est au premier chargement, non poste
53
-		// on restitue les donnees
54
-		if (
55
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
56
-			and !$je_suis_poste
57
-		) {
58
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
59
-			foreach ($vars as $key => $val) {
60
-				if (isset($flux['data'][$key])) {
61
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
62
-						'autosave_clean_value',
63
-						$val
64
-					));
65
-				}
66
-			}
67
-		}
52
+        // si on a un backup en session et qu'on est au premier chargement, non poste
53
+        // on restitue les donnees
54
+        if (
55
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
56
+            and !$je_suis_poste
57
+        ) {
58
+            parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
59
+            foreach ($vars as $key => $val) {
60
+                if (isset($flux['data'][$key])) {
61
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
62
+                        'autosave_clean_value',
63
+                        $val
64
+                    ));
65
+                }
66
+            }
67
+        }
68 68
 
69
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
70
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
71
-		if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72
-			terminer_actualiser_sessions();
73
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
-				session_set('session_autosave_' . $cle_autosave, null);
76
-				// en court sleep pour etre certain que la concurrence est finie
77
-				sleep(1);
78
-				terminer_actualiser_sessions();
79
-			}
80
-		}
69
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
70
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
71
+        if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72
+            terminer_actualiser_sessions();
73
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
+                session_set('session_autosave_' . $cle_autosave, null);
76
+                // en court sleep pour etre certain que la concurrence est finie
77
+                sleep(1);
78
+                terminer_actualiser_sessions();
79
+            }
80
+        }
81 81
 
82 82
 
83
-		/**
84
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
85
-		 */
86
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
83
+        /**
84
+         * Envoyer le input hidden et le bout de js qui l'utilisera
85
+         */
86
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
88 88
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
89 89
 			});/*]]>*/</script>';
90
-	}
90
+    }
91 91
 
92
-	return $flux;
92
+    return $flux;
93 93
 }
94 94
 
95 95
 /**
@@ -103,33 +103,33 @@  discard block
 block discarded – undo
103 103
  * @return array
104 104
  */
105 105
 function cvtautosave_formulaire_traiter($flux) {
106
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
107
-	// on elimine les donnees de la session
108
-	if ($cle_autosave = _request('autosave')) {
109
-		include_spip('inc/session');
110
-		session_set('session_autosave_' . $cle_autosave, null);
111
-	}
106
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
107
+    // on elimine les donnees de la session
108
+    if ($cle_autosave = _request('autosave')) {
109
+        include_spip('inc/session');
110
+        session_set('session_autosave_' . $cle_autosave, null);
111
+    }
112 112
 
113
-	if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
114
-		// delai par defaut avant purge d'un backup de form : 72H
115
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
116
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
117
-		}
118
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
119
-		// purger aussi toutes les vieilles autosave
120
-		$session = $GLOBALS['visiteur_session'];
121
-		foreach ($session as $k => $v) {
122
-			if (strncmp($k, 'session_autosave_', 17) == 0) {
123
-				$timestamp = 0;
124
-				if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
125
-					$timestamp = intval($m[1]);
126
-				}
127
-				if ($timestamp < $time_too_old) {
128
-					session_set($k, null);
129
-				}
130
-			}
131
-		}
132
-	}
113
+    if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
114
+        // delai par defaut avant purge d'un backup de form : 72H
115
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
116
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
117
+        }
118
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
119
+        // purger aussi toutes les vieilles autosave
120
+        $session = $GLOBALS['visiteur_session'];
121
+        foreach ($session as $k => $v) {
122
+            if (strncmp($k, 'session_autosave_', 17) == 0) {
123
+                $timestamp = 0;
124
+                if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
125
+                    $timestamp = intval($m[1]);
126
+                }
127
+                if ($timestamp < $time_too_old) {
128
+                    session_set($k, null);
129
+                }
130
+            }
131
+        }
132
+    }
133 133
 
134
-	return $flux;
134
+    return $flux;
135 135
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 		$je_suis_poste = $flux['args']['je_suis_poste'];
48 48
 
49 49
 		$cle_autosave = serialize($cle_autosave);
50
-		$cle_autosave = $form . '_' . md5($cle_autosave);
50
+		$cle_autosave = $form.'_'.md5($cle_autosave);
51 51
 
52 52
 		// si on a un backup en session et qu'on est au premier chargement, non poste
53 53
 		// on restitue les donnees
54 54
 		if (
55
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+			isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
56 56
 			and !$je_suis_poste
57 57
 		) {
58
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+			parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
59 59
 			foreach ($vars as $key => $val) {
60 60
 				if (isset($flux['data'][$key])) {
61 61
 					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 		if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) {
72 72
 			terminer_actualiser_sessions();
73 73
 			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
74
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
75
-				session_set('session_autosave_' . $cle_autosave, null);
74
+			if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) {
75
+				session_set('session_autosave_'.$cle_autosave, null);
76 76
 				// en court sleep pour etre certain que la concurrence est finie
77 77
 				sleep(1);
78 78
 				terminer_actualiser_sessions();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		 */
86 86
 		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
87 87
 			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
88
-		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88
+		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
89 89
 			});/*]]>*/</script>';
90 90
 	}
91 91
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	// on elimine les donnees de la session
108 108
 	if ($cle_autosave = _request('autosave')) {
109 109
 		include_spip('inc/session');
110
-		session_set('session_autosave_' . $cle_autosave, null);
110
+		session_set('session_autosave_'.$cle_autosave, null);
111 111
 	}
112 112
 
113 113
 	if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) {
Please login to merge, or discard this patch.
ecrire/inc/roles.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			$role = $roles['roles']['defaut'];
151 151
 		}
152 152
 		// where
153
-		$cond = ["$colonne_role=" . sql_quote($role)];
153
+		$cond = ["$colonne_role=".sql_quote($role)];
154 154
 	}
155 155
 
156 156
 	return [$role, $colonne_role, $cond];
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	if ($colonne_role) {
186 186
 		// on ajoute la condition du role aux autres conditions.
187 187
 		if ($role != '*') {
188
-			$cond[] = "$colonne_role=" . sql_quote($role);
188
+			$cond[] = "$colonne_role=".sql_quote($role);
189 189
 		}
190 190
 	}
191 191
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	$all = sql_allfetsel(
370 370
 		"DISTINCT $colone_role",
371 371
 		$l,
372
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
+		'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373 373
 	);
374 374
 	$done[$hash] = array_map('reset', $all);
375 375
 
Please login to merge, or discard this patch.
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 if (!defined('_ECRIRE_INC_VERSION')) {
31
-	return;
31
+    return;
32 32
 }
33 33
 
34 34
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
  *     array : description des roles applicables dans 3 index : colonne, titres, roles
49 49
  **/
50 50
 function roles_presents($objet, $objet_destination = '') {
51
-	$desc = lister_tables_objets_sql(table_objet_sql($objet));
52
-
53
-	// pas de liste de roles, on sort
54
-	if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
-		return false;
56
-	}
57
-
58
-	// on vérifie que la table de liaison existe
59
-	include_spip('action/editer_liens');
60
-	if (!$lien = objet_associable($objet)) {
61
-		return false;
62
-	}
63
-
64
-	// on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
-	$colonne = $desc['roles_colonne'] ?? 'role';
66
-	$trouver_table = charger_fonction('trouver_table', 'base');
67
-	[, $table_lien] = $lien;
68
-	$desc_lien = $trouver_table($table_lien);
69
-	if (!isset($desc_lien['field'][$colonne])) {
70
-		return false;
71
-	}
72
-
73
-	// sur quoi peuvent s'appliquer nos rôles
74
-	if (!$application = $desc['roles_objets']) {
75
-		return false;
76
-	}
77
-
78
-	// destination presente, on restreint si possible
79
-	if ($objet_destination) {
80
-		$objet_destination = table_objet($objet_destination);
81
-
82
-		// pour l'objet
83
-		if (isset($application[$objet_destination])) {
84
-			$application = $application[$objet_destination];
85
-			// sinon pour tous les objets
86
-		} elseif (isset($application['*'])) {
87
-			$application = $application['*'];
88
-		} // sinon tant pis
89
-		else {
90
-			return false;
91
-		}
92
-	}
93
-
94
-	// tout est ok
95
-	return [
96
-		'titres' => $titres,
97
-		'roles' => $application,
98
-		'colonne' => $colonne
99
-	];
51
+    $desc = lister_tables_objets_sql(table_objet_sql($objet));
52
+
53
+    // pas de liste de roles, on sort
54
+    if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
+        return false;
56
+    }
57
+
58
+    // on vérifie que la table de liaison existe
59
+    include_spip('action/editer_liens');
60
+    if (!$lien = objet_associable($objet)) {
61
+        return false;
62
+    }
63
+
64
+    // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
+    $colonne = $desc['roles_colonne'] ?? 'role';
66
+    $trouver_table = charger_fonction('trouver_table', 'base');
67
+    [, $table_lien] = $lien;
68
+    $desc_lien = $trouver_table($table_lien);
69
+    if (!isset($desc_lien['field'][$colonne])) {
70
+        return false;
71
+    }
72
+
73
+    // sur quoi peuvent s'appliquer nos rôles
74
+    if (!$application = $desc['roles_objets']) {
75
+        return false;
76
+    }
77
+
78
+    // destination presente, on restreint si possible
79
+    if ($objet_destination) {
80
+        $objet_destination = table_objet($objet_destination);
81
+
82
+        // pour l'objet
83
+        if (isset($application[$objet_destination])) {
84
+            $application = $application[$objet_destination];
85
+            // sinon pour tous les objets
86
+        } elseif (isset($application['*'])) {
87
+            $application = $application['*'];
88
+        } // sinon tant pis
89
+        else {
90
+            return false;
91
+        }
92
+    }
93
+
94
+    // tout est ok
95
+    return [
96
+        'titres' => $titres,
97
+        'roles' => $application,
98
+        'colonne' => $colonne
99
+    ];
100 100
 }
101 101
 
102 102
 /**
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
  *     Nom de la colonne, sinon vide
111 111
  **/
112 112
 function roles_colonne($objet, $objet_destination) {
113
-	if ($roles = roles_presents($objet, $objet_destination)) {
114
-		return $roles['colonne'];
115
-	}
113
+    if ($roles = roles_presents($objet, $objet_destination)) {
114
+        return $roles['colonne'];
115
+    }
116 116
 
117
-	return '';
117
+    return '';
118 118
 }
119 119
 
120 120
 
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
  *     Liste ('', '', array()) sinon.
137 137
  **/
138 138
 function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) {
139
-	// si des rôles sont possibles, on les utilise
140
-	$role = $colonne_role = ''; # role défini
141
-	// condition du where par defaut
142
-	$cond = [];
143
-	if ($roles = roles_presents($objet, $objet_destination)) {
144
-		$colonne_role = $roles['colonne'];
145
-		// qu'il n'est pas défini
146
-		if (
147
-			!isset($qualif[$colonne_role])
148
-			or !($role = $qualif[$colonne_role])
149
-		) {
150
-			$role = $roles['roles']['defaut'];
151
-		}
152
-		// where
153
-		$cond = ["$colonne_role=" . sql_quote($role)];
154
-	}
155
-
156
-	return [$role, $colonne_role, $cond];
139
+    // si des rôles sont possibles, on les utilise
140
+    $role = $colonne_role = ''; # role défini
141
+    // condition du where par defaut
142
+    $cond = [];
143
+    if ($roles = roles_presents($objet, $objet_destination)) {
144
+        $colonne_role = $roles['colonne'];
145
+        // qu'il n'est pas défini
146
+        if (
147
+            !isset($qualif[$colonne_role])
148
+            or !($role = $qualif[$colonne_role])
149
+        ) {
150
+            $role = $roles['roles']['defaut'];
151
+        }
152
+        // where
153
+        $cond = ["$colonne_role=" . sql_quote($role)];
154
+    }
155
+
156
+    return [$role, $colonne_role, $cond];
157 157
 }
158 158
 
159 159
 /**
@@ -175,21 +175,21 @@  discard block
 block discarded – undo
175 175
  *     Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé)
176 176
  **/
177 177
 function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) {
178
-	// role par défaut, colonne
179
-	[$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet);
178
+    // role par défaut, colonne
179
+    [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet);
180 180
 
181
-	// chercher d'eventuels rôles transmis
182
-	$role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut));
183
-	unset($cond['role']); // cette condition est particuliere...
181
+    // chercher d'eventuels rôles transmis
182
+    $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut));
183
+    unset($cond['role']); // cette condition est particuliere...
184 184
 
185
-	if ($colonne_role) {
186
-		// on ajoute la condition du role aux autres conditions.
187
-		if ($role != '*') {
188
-			$cond[] = "$colonne_role=" . sql_quote($role);
189
-		}
190
-	}
185
+    if ($colonne_role) {
186
+        // on ajoute la condition du role aux autres conditions.
187
+        if ($role != '*') {
188
+            $cond[] = "$colonne_role=" . sql_quote($role);
189
+        }
190
+    }
191 191
 
192
-	return [$cond, $colonne_role, $role];
192
+    return [$cond, $colonne_role, $role];
193 193
 }
194 194
 
195 195
 /**
@@ -211,28 +211,28 @@  discard block
 block discarded – undo
211 211
  */
212 212
 function roles_complets($objet_source, $objet, $id_objet, $objet_lien) {
213 213
 
214
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
215
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
216
-	if ($presents === false) {
217
-		return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
218
-	}
219
-
220
-	// types de roles possibles
221
-	$roles_possibles = $presents['roles']['roles']['choix'];
222
-	// couples id / roles
223
-	$ids = $presents['ids'];
224
-
225
-	// pour chaque groupe, on fait le diff entre tous les roles possibles
226
-	// et les roles attribués à l'élément : s'il en reste, c'est que l'élément
227
-	// n'est pas complet
228
-	$complets = [];
229
-	foreach ($ids as $id => $roles_presents) {
230
-		if (!array_diff($roles_possibles, $roles_presents)) {
231
-			$complets[] = $id;
232
-		}
233
-	}
234
-
235
-	return $complets;
214
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
215
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
216
+    if ($presents === false) {
217
+        return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
218
+    }
219
+
220
+    // types de roles possibles
221
+    $roles_possibles = $presents['roles']['roles']['choix'];
222
+    // couples id / roles
223
+    $ids = $presents['ids'];
224
+
225
+    // pour chaque groupe, on fait le diff entre tous les roles possibles
226
+    // et les roles attribués à l'élément : s'il en reste, c'est que l'élément
227
+    // n'est pas complet
228
+    $complets = [];
229
+    foreach ($ids as $id => $roles_presents) {
230
+        if (!array_diff($roles_possibles, $roles_presents)) {
231
+            $complets[] = $id;
232
+        }
233
+    }
234
+
235
+    return $complets;
236 236
 }
237 237
 
238 238
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) {
251 251
 
252
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
253
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
254
-	if ($presents === false) {
255
-		return [];
256
-	}
252
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
253
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
254
+    if ($presents === false) {
255
+        return [];
256
+    }
257 257
 
258
-	if (!isset($presents['ids'][$id_objet_source])) {
259
-		return [];
260
-	}
258
+    if (!isset($presents['ids'][$id_objet_source])) {
259
+        return [];
260
+    }
261 261
 
262
-	return $presents['ids'][$id_objet_source];
262
+    return $presents['ids'][$id_objet_source];
263 263
 }
264 264
 
265 265
 
@@ -287,47 +287,47 @@  discard block
 block discarded – undo
287 287
  *     - False si pas de role déclarés
288 288
  */
289 289
 function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) {
290
-	static $done = [];
291
-
292
-	// stocker le résultat
293
-	$hash = "$objet_source-$objet-$id_objet-$objet_lien";
294
-	if (isset($done[$hash])) {
295
-		return $done[$hash];
296
-	}
297
-
298
-	// pas de roles sur ces objets, on sort
299
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
300
-	if (!$roles) {
301
-		return $done[$hash] = false;
302
-	}
303
-
304
-	// inspiré de lister_objets_lies()
305
-	if ($objet_lien == $objet) {
306
-		$res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
307
-	} else {
308
-		$res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
309
-	}
310
-
311
-	// types de roles possibles
312
-	$roles_possibles = $roles['roles']['choix'];
313
-	// colonne du role
314
-	$colonne = $roles['colonne'];
315
-
316
-	// on recupere par id, et role existant
317
-	$ids = [];
318
-	while ($row = array_shift($res)) {
319
-		$id = $row[$objet_source];
320
-		if (!isset($ids[$id])) {
321
-			$ids[$id] = [];
322
-		}
323
-		// tableau des roles présents
324
-		$ids[$id][] = $row[$colonne];
325
-	}
326
-
327
-	return $done[$hash] = [
328
-		'roles' => $roles,
329
-		'ids' => $ids
330
-	];
290
+    static $done = [];
291
+
292
+    // stocker le résultat
293
+    $hash = "$objet_source-$objet-$id_objet-$objet_lien";
294
+    if (isset($done[$hash])) {
295
+        return $done[$hash];
296
+    }
297
+
298
+    // pas de roles sur ces objets, on sort
299
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
300
+    if (!$roles) {
301
+        return $done[$hash] = false;
302
+    }
303
+
304
+    // inspiré de lister_objets_lies()
305
+    if ($objet_lien == $objet) {
306
+        $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
307
+    } else {
308
+        $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
309
+    }
310
+
311
+    // types de roles possibles
312
+    $roles_possibles = $roles['roles']['choix'];
313
+    // colonne du role
314
+    $colonne = $roles['colonne'];
315
+
316
+    // on recupere par id, et role existant
317
+    $ids = [];
318
+    while ($row = array_shift($res)) {
319
+        $id = $row[$objet_source];
320
+        if (!isset($ids[$id])) {
321
+            $ids[$id] = [];
322
+        }
323
+        // tableau des roles présents
324
+        $ids[$id][] = $row[$colonne];
325
+    }
326
+
327
+    return $done[$hash] = [
328
+        'roles' => $roles,
329
+        'ids' => $ids
330
+    ];
331 331
 }
332 332
 
333 333
 
@@ -345,33 +345,33 @@  discard block
 block discarded – undo
345 345
  *     - false si pas de role déclarés
346 346
  */
347 347
 function roles_connus_en_base($objet_source, $objet, $objet_lien) {
348
-	static $done = [];
349
-
350
-	// stocker le résultat
351
-	$hash = "$objet_source-$objet-$objet_lien";
352
-	if (isset($done[$hash])) {
353
-		return $done[$hash];
354
-	}
355
-
356
-	if (!$lien = objet_associable($objet_lien)) {
357
-		return $done[$hash] = false;
358
-	}
359
-
360
-	// pas de roles sur ces objets, on sort
361
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
362
-	if (!$roles) {
363
-		return $done[$hash] = false;
364
-	}
365
-
366
-	[$primary, $l] = $lien;
367
-	$colone_role = $roles['colonne'];
368
-
369
-	$all = sql_allfetsel(
370
-		"DISTINCT $colone_role",
371
-		$l,
372
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373
-	);
374
-	$done[$hash] = array_map('reset', $all);
375
-
376
-	return $done[$hash];
348
+    static $done = [];
349
+
350
+    // stocker le résultat
351
+    $hash = "$objet_source-$objet-$objet_lien";
352
+    if (isset($done[$hash])) {
353
+        return $done[$hash];
354
+    }
355
+
356
+    if (!$lien = objet_associable($objet_lien)) {
357
+        return $done[$hash] = false;
358
+    }
359
+
360
+    // pas de roles sur ces objets, on sort
361
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
362
+    if (!$roles) {
363
+        return $done[$hash] = false;
364
+    }
365
+
366
+    [$primary, $l] = $lien;
367
+    $colone_role = $roles['colonne'];
368
+
369
+    $all = sql_allfetsel(
370
+        "DISTINCT $colone_role",
371
+        $l,
372
+        'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
373
+    );
374
+    $done[$hash] = array_map('reset', $all);
375
+
376
+    return $done[$hash];
377 377
 }
Please login to merge, or discard this patch.
ecrire/inc/utils.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -364,8 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 	if (!isset($regs[2])) {
366 366
 		$niveau = _LOG_INFO;
367
-	}
368
-	else {
367
+	} else {
369 368
 		$niveau = intval($regs[2]);
370 369
 	}
371 370
 
@@ -1475,8 +1474,7 @@  discard block
 block discarded – undo
1475 1474
 	) {
1476 1475
 		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1477 1476
 			return $themefiles["$subdir$file"] = $fsize;
1478
-		}
1479
-		else {
1477
+		} else {
1480 1478
 			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1481 1479
 		}
1482 1480
 	}
@@ -3496,8 +3494,7 @@  discard block
 block discarded – undo
3496 3494
 		if (!in_array('svg', $formats)) {
3497 3495
 			$formats[] = 'svg';
3498 3496
 		}
3499
-	}
3500
-	else {
3497
+	} else {
3501 3498
 		$formats = array_diff($formats, ['svg']);
3502 3499
 	}
3503 3500
 	return $formats;
Please login to merge, or discard this patch.
Indentation   +2265 added lines, -2266 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,71 +48,71 @@  discard block
 block discarded – undo
48 48
  *     Nom de la fonction, ou false.
49 49
  */
50 50
 function charger_fonction($nom, $dossier = 'exec', $continue = false) {
51
-	static $echecs = [];
52
-
53
-	if (strlen($dossier) and substr($dossier, -1) != '/') {
54
-		$dossier .= '/';
55
-	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
57
-
58
-	if (function_exists($f)) {
59
-		return $f;
60
-	}
61
-	if (function_exists($g = $f . '_dist')) {
62
-		return $g;
63
-	}
64
-
65
-	if (isset($echecs[$f])) {
66
-		return $echecs[$f];
67
-	}
68
-	// Sinon charger le fichier de declaration si plausible
69
-
70
-	if (!preg_match(',^\w+$,', $f)) {
71
-		if ($continue) {
72
-			return false;
73
-		} //appel interne, on passe
74
-		include_spip('inc/minipres');
75
-		echo minipres();
76
-		exit;
77
-	}
78
-
79
-	// passer en minuscules (cf les balises de formulaires)
80
-	// et inclure le fichier
81
-	if (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
83
-		// si le fichier truc/machin/nom.php n'existe pas,
84
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
-	) {
87
-		include_spip(substr($dossier, 0, -1));
88
-	}
89
-	if (function_exists($f)) {
90
-		return $f;
91
-	}
92
-	if (function_exists($g)) {
93
-		return $g;
94
-	}
95
-
96
-	if ($continue) {
97
-		return $echecs[$f] = false;
98
-	}
99
-
100
-	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
102
-		($inc ? '' : " (fichier $d absent de $dossier)"));
103
-
104
-	include_spip('inc/minipres');
105
-	echo minipres(
106
-		_T('forum_titre_erreur'),
107
-		$inc ?
108
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
109
-			. '<br />'
110
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
111
-			:
112
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
-		['all_inline' => true,'status' => 404]
114
-	);
115
-	exit;
51
+    static $echecs = [];
52
+
53
+    if (strlen($dossier) and substr($dossier, -1) != '/') {
54
+        $dossier .= '/';
55
+    }
56
+    $f = str_replace('/', '_', $dossier) . $nom;
57
+
58
+    if (function_exists($f)) {
59
+        return $f;
60
+    }
61
+    if (function_exists($g = $f . '_dist')) {
62
+        return $g;
63
+    }
64
+
65
+    if (isset($echecs[$f])) {
66
+        return $echecs[$f];
67
+    }
68
+    // Sinon charger le fichier de declaration si plausible
69
+
70
+    if (!preg_match(',^\w+$,', $f)) {
71
+        if ($continue) {
72
+            return false;
73
+        } //appel interne, on passe
74
+        include_spip('inc/minipres');
75
+        echo minipres();
76
+        exit;
77
+    }
78
+
79
+    // passer en minuscules (cf les balises de formulaires)
80
+    // et inclure le fichier
81
+    if (
82
+        !$inc = include_spip($dossier . ($d = strtolower($nom)))
83
+        // si le fichier truc/machin/nom.php n'existe pas,
84
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
+    ) {
87
+        include_spip(substr($dossier, 0, -1));
88
+    }
89
+    if (function_exists($f)) {
90
+        return $f;
91
+    }
92
+    if (function_exists($g)) {
93
+        return $g;
94
+    }
95
+
96
+    if ($continue) {
97
+        return $echecs[$f] = false;
98
+    }
99
+
100
+    // Echec : message d'erreur
101
+    spip_log("fonction $nom ($f ou $g) indisponible" .
102
+        ($inc ? '' : " (fichier $d absent de $dossier)"));
103
+
104
+    include_spip('inc/minipres');
105
+    echo minipres(
106
+        _T('forum_titre_erreur'),
107
+        $inc ?
108
+            _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
109
+            . '<br />'
110
+            . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
111
+            :
112
+            _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
+        ['all_inline' => true,'status' => 404]
114
+    );
115
+    exit;
116 116
 }
117 117
 
118 118
 /**
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
  * @return bool
123 123
  */
124 124
 function include_once_check($file) {
125
-	if (file_exists($file)) {
126
-		include_once $file;
125
+    if (file_exists($file)) {
126
+        include_once $file;
127 127
 
128
-		return true;
129
-	}
130
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
131
-	$crash = ($crash ?: []);
132
-	$crash[$file] = true;
133
-	ecrire_meta('message_crash_plugins', serialize($crash));
128
+        return true;
129
+    }
130
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
131
+    $crash = ($crash ?: []);
132
+    $crash[$file] = true;
133
+    ecrire_meta('message_crash_plugins', serialize($crash));
134 134
 
135
-	return false;
135
+    return false;
136 136
 }
137 137
 
138 138
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  *     - string : chemin du fichier trouvé
157 157
  **/
158 158
 function include_spip($f, $include = true) {
159
-	return find_in_path($f . '.php', '', $include);
159
+    return find_in_path($f . '.php', '', $include);
160 160
 }
161 161
 
162 162
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *     - string : chemin du fichier trouvé
177 177
  **/
178 178
 function require_spip($f) {
179
-	return find_in_path($f . '.php', '', 'required');
179
+    return find_in_path($f . '.php', '', 'required');
180 180
 }
181 181
 
182 182
 
@@ -185,27 +185,27 @@  discard block
 block discarded – undo
185 185
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
186 186
  */
187 187
 function include_fichiers_fonctions() {
188
-	static $done = false;
189
-	if (!$done) {
190
-		include_spip('inc/lang');
191
-
192
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
193
-		// donc il faut l'inclure "en globals"
194
-		if ($f = find_in_path('mes_fonctions.php')) {
195
-			global $dossier_squelettes;
196
-			include_once(_ROOT_CWD . $f);
197
-		}
198
-
199
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
200
-			// chargement optimise precompile
201
-			include_once(_CACHE_PLUGINS_FCT);
202
-		}
203
-		if (test_espace_prive()) {
204
-			include_spip('inc/filtres_ecrire');
205
-		}
206
-		include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
207
-		$done = true;
208
-	}
188
+    static $done = false;
189
+    if (!$done) {
190
+        include_spip('inc/lang');
191
+
192
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
193
+        // donc il faut l'inclure "en globals"
194
+        if ($f = find_in_path('mes_fonctions.php')) {
195
+            global $dossier_squelettes;
196
+            include_once(_ROOT_CWD . $f);
197
+        }
198
+
199
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
200
+            // chargement optimise precompile
201
+            include_once(_CACHE_PLUGINS_FCT);
202
+        }
203
+        if (test_espace_prive()) {
204
+            include_spip('inc/filtres_ecrire');
205
+        }
206
+        include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
207
+        $done = true;
208
+    }
209 209
 }
210 210
 
211 211
 /**
@@ -231,23 +231,23 @@  discard block
 block discarded – undo
231 231
  *     Les paramètres du pipeline modifiés
232 232
  **/
233 233
 function minipipe($fonc, &$val) {
234
-	// fonction
235
-	if (function_exists($fonc)) {
236
-		$val = $fonc($val);
237
-	} // Class::Methode
238
-	else {
239
-		if (
240
-			preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
241
-			and $methode = [$regs[1], $regs[2]]
242
-			and is_callable($methode)
243
-		) {
244
-			$val = $methode($val);
245
-		} else {
246
-			spip_log("Erreur - '$fonc' non definie !");
247
-		}
248
-	}
249
-
250
-	return $val;
234
+    // fonction
235
+    if (function_exists($fonc)) {
236
+        $val = $fonc($val);
237
+    } // Class::Methode
238
+    else {
239
+        if (
240
+            preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
241
+            and $methode = [$regs[1], $regs[2]]
242
+            and is_callable($methode)
243
+        ) {
244
+            $val = $methode($val);
245
+        } else {
246
+            spip_log("Erreur - '$fonc' non definie !");
247
+        }
248
+    }
249
+
250
+    return $val;
251 251
 }
252 252
 
253 253
 /**
@@ -278,46 +278,46 @@  discard block
 block discarded – undo
278 278
  *     Résultat
279 279
  */
280 280
 function pipeline($action, $val = null) {
281
-	static $charger;
282
-
283
-	// chargement initial des fonctions mises en cache, ou generation du cache
284
-	if (!$charger) {
285
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
286
-			include_spip('inc/plugin');
287
-			// generer les fichiers php precompiles
288
-			// de chargement des plugins et des pipelines
289
-			actualise_plugins_actifs();
290
-			if (!($ok = @is_readable($charger))) {
291
-				spip_log("fichier $charger pas cree");
292
-			}
293
-		}
294
-
295
-		if ($ok) {
296
-			include_once $charger;
297
-		}
298
-	}
299
-
300
-	// appliquer notre fonction si elle existe
301
-	$fonc = 'execute_pipeline_' . strtolower($action);
302
-	if (function_exists($fonc)) {
303
-		$val = $fonc($val);
304
-	} // plantage ?
305
-	else {
306
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
307
-	}
308
-
309
-	// si le flux est une table avec 2 cle args&data
310
-	// on ne ressort du pipe que les donnees dans 'data'
311
-	// array_key_exists pour php 4.1.0
312
-	if (
313
-		is_array($val)
314
-		and count($val) == 2
315
-		and (array_key_exists('data', $val))
316
-	) {
317
-		$val = $val['data'];
318
-	}
319
-
320
-	return $val;
281
+    static $charger;
282
+
283
+    // chargement initial des fonctions mises en cache, ou generation du cache
284
+    if (!$charger) {
285
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
286
+            include_spip('inc/plugin');
287
+            // generer les fichiers php precompiles
288
+            // de chargement des plugins et des pipelines
289
+            actualise_plugins_actifs();
290
+            if (!($ok = @is_readable($charger))) {
291
+                spip_log("fichier $charger pas cree");
292
+            }
293
+        }
294
+
295
+        if ($ok) {
296
+            include_once $charger;
297
+        }
298
+    }
299
+
300
+    // appliquer notre fonction si elle existe
301
+    $fonc = 'execute_pipeline_' . strtolower($action);
302
+    if (function_exists($fonc)) {
303
+        $val = $fonc($val);
304
+    } // plantage ?
305
+    else {
306
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
307
+    }
308
+
309
+    // si le flux est une table avec 2 cle args&data
310
+    // on ne ressort du pipe que les donnees dans 'data'
311
+    // array_key_exists pour php 4.1.0
312
+    if (
313
+        is_array($val)
314
+        and count($val) == 2
315
+        and (array_key_exists('data', $val))
316
+    ) {
317
+        $val = $val['data'];
318
+    }
319
+
320
+    return $val;
321 321
 }
322 322
 
323 323
 /**
@@ -361,38 +361,38 @@  discard block
 block discarded – undo
361 361
  *     paramètre est planté pour cause de compatibilité ascendante.
362 362
  */
363 363
 function spip_log($message = null, $name = null) {
364
-	static $pre = [];
365
-	static $log;
366
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
367
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
368
-		$logname = null;
369
-	}
370
-	if (!isset($regs[2])) {
371
-		$niveau = _LOG_INFO;
372
-	}
373
-	else {
374
-		$niveau = intval($regs[2]);
375
-	}
376
-
377
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
378
-		if (!$pre) {
379
-			$pre = [
380
-				_LOG_HS => 'HS:',
381
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
382
-				_LOG_CRITIQUE => 'CRITIQUE:',
383
-				_LOG_ERREUR => 'ERREUR:',
384
-				_LOG_AVERTISSEMENT => 'WARNING:',
385
-				_LOG_INFO_IMPORTANTE => '!INFO:',
386
-				_LOG_INFO => 'info:',
387
-				_LOG_DEBUG => 'debug:'
388
-			];
389
-			$log = charger_fonction('log', 'inc');
390
-		}
391
-		if (!is_string($message)) {
392
-			$message = print_r($message, true);
393
-		}
394
-		$log($pre[$niveau] . ' ' . $message, $logname);
395
-	}
364
+    static $pre = [];
365
+    static $log;
366
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
367
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
368
+        $logname = null;
369
+    }
370
+    if (!isset($regs[2])) {
371
+        $niveau = _LOG_INFO;
372
+    }
373
+    else {
374
+        $niveau = intval($regs[2]);
375
+    }
376
+
377
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
378
+        if (!$pre) {
379
+            $pre = [
380
+                _LOG_HS => 'HS:',
381
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
382
+                _LOG_CRITIQUE => 'CRITIQUE:',
383
+                _LOG_ERREUR => 'ERREUR:',
384
+                _LOG_AVERTISSEMENT => 'WARNING:',
385
+                _LOG_INFO_IMPORTANTE => '!INFO:',
386
+                _LOG_INFO => 'info:',
387
+                _LOG_DEBUG => 'debug:'
388
+            ];
389
+            $log = charger_fonction('log', 'inc');
390
+        }
391
+        if (!is_string($message)) {
392
+            $message = print_r($message, true);
393
+        }
394
+        $log($pre[$niveau] . ' ' . $message, $logname);
395
+    }
396 396
 }
397 397
 
398 398
 /**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
  * @param array $opt Tableau d'options
404 404
  **/
405 405
 function journal($phrase, $opt = []) {
406
-	$journal = charger_fonction('journal', 'inc');
407
-	$journal($phrase, $opt);
406
+    $journal = charger_fonction('journal', 'inc');
407
+    $journal($phrase, $opt);
408 408
 }
409 409
 
410 410
 
@@ -423,37 +423,37 @@  discard block
 block discarded – undo
423 423
  **/
424 424
 function _request($var, $c = false) {
425 425
 
426
-	if (is_array($c)) {
427
-		return $c[$var] ?? null;
428
-	}
429
-
430
-	if (isset($_GET[$var])) {
431
-		$a = $_GET[$var];
432
-	} elseif (isset($_POST[$var])) {
433
-		$a = $_POST[$var];
434
-	} else {
435
-		return null;
436
-	}
437
-
438
-	// Si on est en ajax et en POST tout a ete encode
439
-	// via encodeURIComponent, il faut donc repasser
440
-	// dans le charset local...
441
-	if (
442
-		defined('_AJAX')
443
-		and _AJAX
444
-		and isset($GLOBALS['meta']['charset'])
445
-		and $GLOBALS['meta']['charset'] != 'utf-8'
446
-		and is_string($a)
447
-		// check rapide mais pas fiable
448
-		and preg_match(',[\x80-\xFF],', $a)
449
-		// check fiable
450
-		and include_spip('inc/charsets')
451
-		and is_utf8($a)
452
-	) {
453
-		return importer_charset($a, 'utf-8');
454
-	}
455
-
456
-	return $a;
426
+    if (is_array($c)) {
427
+        return $c[$var] ?? null;
428
+    }
429
+
430
+    if (isset($_GET[$var])) {
431
+        $a = $_GET[$var];
432
+    } elseif (isset($_POST[$var])) {
433
+        $a = $_POST[$var];
434
+    } else {
435
+        return null;
436
+    }
437
+
438
+    // Si on est en ajax et en POST tout a ete encode
439
+    // via encodeURIComponent, il faut donc repasser
440
+    // dans le charset local...
441
+    if (
442
+        defined('_AJAX')
443
+        and _AJAX
444
+        and isset($GLOBALS['meta']['charset'])
445
+        and $GLOBALS['meta']['charset'] != 'utf-8'
446
+        and is_string($a)
447
+        // check rapide mais pas fiable
448
+        and preg_match(',[\x80-\xFF],', $a)
449
+        // check fiable
450
+        and include_spip('inc/charsets')
451
+        and is_utf8($a)
452
+    ) {
453
+        return importer_charset($a, 'utf-8');
454
+    }
455
+
456
+    return $a;
457 457
 }
458 458
 
459 459
 
@@ -471,22 +471,22 @@  discard block
 block discarded – undo
471 471
  *     - false sinon
472 472
  **/
473 473
 function set_request($var, $val = null, $c = false) {
474
-	if (is_array($c)) {
475
-		unset($c[$var]);
476
-		if ($val !== null) {
477
-			$c[$var] = $val;
478
-		}
474
+    if (is_array($c)) {
475
+        unset($c[$var]);
476
+        if ($val !== null) {
477
+            $c[$var] = $val;
478
+        }
479 479
 
480
-		return $c;
481
-	}
480
+        return $c;
481
+    }
482 482
 
483
-	unset($_GET[$var]);
484
-	unset($_POST[$var]);
485
-	if ($val !== null) {
486
-		$_GET[$var] = $val;
487
-	}
483
+    unset($_GET[$var]);
484
+    unset($_POST[$var]);
485
+    if ($val !== null) {
486
+        $_GET[$var] = $val;
487
+    }
488 488
 
489
-	return false; # n'affecte pas $c
489
+    return false; # n'affecte pas $c
490 490
 }
491 491
 
492 492
 /**
@@ -506,25 +506,25 @@  discard block
 block discarded – undo
506 506
  * @return array|mixed|string
507 507
  */
508 508
 function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
509
-	if (is_array($value)) {
510
-		if ($key == '*') {
511
-			$key = array_keys($value);
512
-		}
513
-		if (!is_array($key)) {
514
-			$key = [$key];
515
-		}
516
-		foreach ($key as $k) {
517
-			if (!empty($value[$k])) {
518
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
519
-			}
520
-		}
521
-		return $value;
522
-	}
523
-	// si la valeur vient des GET ou POST on la sanitize
524
-	if (!empty($value) and $value == _request($key)) {
525
-		$value = $sanitize_function($value);
526
-	}
527
-	return $value;
509
+    if (is_array($value)) {
510
+        if ($key == '*') {
511
+            $key = array_keys($value);
512
+        }
513
+        if (!is_array($key)) {
514
+            $key = [$key];
515
+        }
516
+        foreach ($key as $k) {
517
+            if (!empty($value[$k])) {
518
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
519
+            }
520
+        }
521
+        return $value;
522
+    }
523
+    // si la valeur vient des GET ou POST on la sanitize
524
+    if (!empty($value) and $value == _request($key)) {
525
+        $value = $sanitize_function($value);
526
+    }
527
+    return $value;
528 528
 }
529 529
 
530 530
 /**
@@ -532,23 +532,22 @@  discard block
 block discarded – undo
532 532
  *
533 533
  * On est sur le web, on exclut certains protocoles,
534 534
  * notamment 'file://', 'php://' et d'autres…
535
-
536 535
  * @param string $url
537 536
  * @return bool
538 537
  */
539 538
 function tester_url_absolue($url) {
540
-	$url = trim($url ?? '');
541
-	if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
542
-		if (
543
-			isset($m[1])
544
-			and $p = strtolower(rtrim($m[1], ':'))
545
-			and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
546
-		) {
547
-			return false;
548
-		}
549
-		return true;
550
-	}
551
-	return false;
539
+    $url = trim($url ?? '');
540
+    if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
541
+        if (
542
+            isset($m[1])
543
+            and $p = strtolower(rtrim($m[1], ':'))
544
+            and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
545
+        ) {
546
+            return false;
547
+        }
548
+        return true;
549
+    }
550
+    return false;
552 551
 }
553 552
 
554 553
 /**
@@ -570,100 +569,100 @@  discard block
 block discarded – undo
570 569
  * @return string URL
571 570
  */
572 571
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
573
-	// requete erronnee : plusieurs variable dans $c et aucun $v
574
-	if (strpos($c, '|') !== false and is_null($v)) {
575
-		return null;
576
-	}
577
-
578
-	// lever l'#ancre
579
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
580
-		$url = $r[1];
581
-		$ancre = $r[2];
582
-	} else {
583
-		$ancre = '';
584
-	}
585
-
586
-	// eclater
587
-	$url = preg_split(',[?]|&amp;|&,', $url);
588
-
589
-	// recuperer la base
590
-	$a = array_shift($url);
591
-	if (!$a) {
592
-		$a = './';
593
-	}
594
-
595
-	// preparer la regexp de maniere securisee
596
-	$regexp = explode('|', $c);
597
-	foreach ($regexp as $r => $e) {
598
-		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
599
-	}
600
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
601
-	$ajouts = array_flip(explode('|', $c));
602
-	$u = is_array($v) ? $v : rawurlencode((string) $v);
603
-	$testv = (is_array($v) ? count($v) : strlen((string) $v));
604
-	$v_read = null;
605
-	// lire les variables et agir
606
-	foreach ($url as $n => $val) {
607
-		if (preg_match($regexp, urldecode($val), $r)) {
608
-			$r = array_pad($r, 3, null);
609
-			if ($v === null) {
610
-				// c'est un tableau, on memorise les valeurs
611
-				if (substr($r[1], -2) == '[]') {
612
-					if (!$v_read) {
613
-						$v_read = [];
614
-					}
615
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
616
-				} // c'est un scalaire, on retourne direct
617
-				else {
618
-					return $r[2] ? substr($r[2], 1) : '';
619
-				}
620
-			} // suppression
621
-			elseif (!$testv) {
622
-				unset($url[$n]);
623
-			}
624
-			// Ajout. Pour une variable, remplacer au meme endroit,
625
-			// pour un tableau ce sera fait dans la prochaine boucle
626
-			elseif (substr($r[1], -2) != '[]') {
627
-				$url[$n] = $r[1] . '=' . $u;
628
-				unset($ajouts[$r[1]]);
629
-			}
630
-			// Pour les tableaux on laisse tomber les valeurs de
631
-			// départ, on remplira à l'étape suivante
632
-			else {
633
-				unset($url[$n]);
634
-			}
635
-		}
636
-	}
637
-
638
-	// traiter les parametres pas encore trouves
639
-	if (
640
-		$v === null
641
-		and $args = func_get_args()
642
-		and count($args) == 2
643
-	) {
644
-		return $v_read; // rien trouve ou un tableau
645
-	} elseif ($testv) {
646
-		foreach ($ajouts as $k => $n) {
647
-			if (!is_array($v)) {
648
-				$url[] = $k . '=' . $u;
649
-			} else {
650
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
651
-				foreach ($v as $w) {
652
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
653
-				}
654
-			}
655
-		}
656
-	}
657
-
658
-	// eliminer les vides
659
-	$url = array_filter($url);
660
-
661
-	// recomposer l'adresse
662
-	if ($url) {
663
-		$a .= '?' . join($sep, $url);
664
-	}
665
-
666
-	return $a . $ancre;
572
+    // requete erronnee : plusieurs variable dans $c et aucun $v
573
+    if (strpos($c, '|') !== false and is_null($v)) {
574
+        return null;
575
+    }
576
+
577
+    // lever l'#ancre
578
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
579
+        $url = $r[1];
580
+        $ancre = $r[2];
581
+    } else {
582
+        $ancre = '';
583
+    }
584
+
585
+    // eclater
586
+    $url = preg_split(',[?]|&amp;|&,', $url);
587
+
588
+    // recuperer la base
589
+    $a = array_shift($url);
590
+    if (!$a) {
591
+        $a = './';
592
+    }
593
+
594
+    // preparer la regexp de maniere securisee
595
+    $regexp = explode('|', $c);
596
+    foreach ($regexp as $r => $e) {
597
+        $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
598
+    }
599
+    $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
600
+    $ajouts = array_flip(explode('|', $c));
601
+    $u = is_array($v) ? $v : rawurlencode((string) $v);
602
+    $testv = (is_array($v) ? count($v) : strlen((string) $v));
603
+    $v_read = null;
604
+    // lire les variables et agir
605
+    foreach ($url as $n => $val) {
606
+        if (preg_match($regexp, urldecode($val), $r)) {
607
+            $r = array_pad($r, 3, null);
608
+            if ($v === null) {
609
+                // c'est un tableau, on memorise les valeurs
610
+                if (substr($r[1], -2) == '[]') {
611
+                    if (!$v_read) {
612
+                        $v_read = [];
613
+                    }
614
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
615
+                } // c'est un scalaire, on retourne direct
616
+                else {
617
+                    return $r[2] ? substr($r[2], 1) : '';
618
+                }
619
+            } // suppression
620
+            elseif (!$testv) {
621
+                unset($url[$n]);
622
+            }
623
+            // Ajout. Pour une variable, remplacer au meme endroit,
624
+            // pour un tableau ce sera fait dans la prochaine boucle
625
+            elseif (substr($r[1], -2) != '[]') {
626
+                $url[$n] = $r[1] . '=' . $u;
627
+                unset($ajouts[$r[1]]);
628
+            }
629
+            // Pour les tableaux on laisse tomber les valeurs de
630
+            // départ, on remplira à l'étape suivante
631
+            else {
632
+                unset($url[$n]);
633
+            }
634
+        }
635
+    }
636
+
637
+    // traiter les parametres pas encore trouves
638
+    if (
639
+        $v === null
640
+        and $args = func_get_args()
641
+        and count($args) == 2
642
+    ) {
643
+        return $v_read; // rien trouve ou un tableau
644
+    } elseif ($testv) {
645
+        foreach ($ajouts as $k => $n) {
646
+            if (!is_array($v)) {
647
+                $url[] = $k . '=' . $u;
648
+            } else {
649
+                $id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
650
+                foreach ($v as $w) {
651
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
652
+                }
653
+            }
654
+        }
655
+    }
656
+
657
+    // eliminer les vides
658
+    $url = array_filter($url);
659
+
660
+    // recomposer l'adresse
661
+    if ($url) {
662
+        $a .= '?' . join($sep, $url);
663
+    }
664
+
665
+    return $a . $ancre;
667 666
 }
668 667
 
669 668
 /**
@@ -681,21 +680,21 @@  discard block
 block discarded – undo
681 680
  * @return string
682 681
  */
683 682
 function ancre_url($url, $ancre) {
684
-	// lever l'#ancre
685
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
686
-		$url = $r[1];
687
-	}
688
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
689
-		if (!function_exists('translitteration')) {
690
-			include_spip('inc/charsets');
691
-		}
692
-		$ancre = preg_replace(
693
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
694
-			['', '-'],
695
-			translitteration($ancre)
696
-		);
697
-	}
698
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
683
+    // lever l'#ancre
684
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
685
+        $url = $r[1];
686
+    }
687
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
688
+        if (!function_exists('translitteration')) {
689
+            include_spip('inc/charsets');
690
+        }
691
+        $ancre = preg_replace(
692
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
693
+            ['', '-'],
694
+            translitteration($ancre)
695
+        );
696
+    }
697
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
699 698
 }
700 699
 
701 700
 /**
@@ -705,16 +704,16 @@  discard block
 block discarded – undo
705 704
  * @return string
706 705
  */
707 706
 function nettoyer_uri($reset = null) {
708
-	static $done = false;
709
-	static $propre = '';
710
-	if (!is_null($reset)) {
711
-		return $propre = $reset;
712
-	}
713
-	if ($done) {
714
-		return $propre;
715
-	}
716
-	$done = true;
717
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
707
+    static $done = false;
708
+    static $propre = '';
709
+    if (!is_null($reset)) {
710
+        return $propre = $reset;
711
+    }
712
+    if ($done) {
713
+        return $propre;
714
+    }
715
+    $done = true;
716
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
718 717
 }
719 718
 
720 719
 /**
@@ -726,16 +725,16 @@  discard block
 block discarded – undo
726 725
  * @return string
727 726
  */
728 727
 function nettoyer_uri_var($request_uri) {
729
-	$uri1 = $request_uri;
730
-	do {
731
-		$uri = $uri1;
732
-		$uri1 = preg_replace(
733
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
734
-			'\1',
735
-			$uri
736
-		);
737
-	} while ($uri <> $uri1);
738
-	return preg_replace(',[?&]$,', '', $uri1);
728
+    $uri1 = $request_uri;
729
+    do {
730
+        $uri = $uri1;
731
+        $uri1 = preg_replace(
732
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
733
+            '\1',
734
+            $uri
735
+        );
736
+    } while ($uri <> $uri1);
737
+    return preg_replace(',[?&]$,', '', $uri1);
739 738
 }
740 739
 
741 740
 
@@ -749,48 +748,48 @@  discard block
 block discarded – undo
749 748
  *    URL vers soi-même
750 749
  **/
751 750
 function self($amp = '&amp;', $root = false) {
752
-	$url = nettoyer_uri();
753
-	if (
754
-		!$root
755
-		and (
756
-			// si pas de profondeur on peut tronquer
757
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
758
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
759
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
760
-	) {
761
-		$url = preg_replace(',^[^?]*/,', '', $url);
762
-	}
763
-	// ajouter le cas echeant les variables _POST['id_...']
764
-	foreach ($_POST as $v => $c) {
765
-		if (substr($v, 0, 3) == 'id_') {
766
-			$url = parametre_url($url, $v, $c, '&');
767
-		}
768
-	}
769
-
770
-	// supprimer les variables sans interet
771
-	if (test_espace_prive()) {
772
-		$url = preg_replace(',([?&])('
773
-			. 'lang|show_docs|'
774
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
775
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
776
-		$url = preg_replace(',[&]$,', '\1', $url);
777
-	}
778
-
779
-	// eviter les hacks
780
-	include_spip('inc/filtres_mini');
781
-	$url = spip_htmlspecialchars($url);
782
-
783
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
784
-
785
-	// &amp; ?
786
-	if ($amp != '&amp;') {
787
-		$url = str_replace('&amp;', $amp, $url);
788
-	}
789
-
790
-	// Si ca demarre par ? ou vide, donner './'
791
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
792
-
793
-	return $url;
751
+    $url = nettoyer_uri();
752
+    if (
753
+        !$root
754
+        and (
755
+            // si pas de profondeur on peut tronquer
756
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
757
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
758
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
759
+    ) {
760
+        $url = preg_replace(',^[^?]*/,', '', $url);
761
+    }
762
+    // ajouter le cas echeant les variables _POST['id_...']
763
+    foreach ($_POST as $v => $c) {
764
+        if (substr($v, 0, 3) == 'id_') {
765
+            $url = parametre_url($url, $v, $c, '&');
766
+        }
767
+    }
768
+
769
+    // supprimer les variables sans interet
770
+    if (test_espace_prive()) {
771
+        $url = preg_replace(',([?&])('
772
+            . 'lang|show_docs|'
773
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
774
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
775
+        $url = preg_replace(',[&]$,', '\1', $url);
776
+    }
777
+
778
+    // eviter les hacks
779
+    include_spip('inc/filtres_mini');
780
+    $url = spip_htmlspecialchars($url);
781
+
782
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
783
+
784
+    // &amp; ?
785
+    if ($amp != '&amp;') {
786
+        $url = str_replace('&amp;', $amp, $url);
787
+    }
788
+
789
+    // Si ca demarre par ? ou vide, donner './'
790
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
791
+
792
+    return $url;
794 793
 }
795 794
 
796 795
 
@@ -801,7 +800,7 @@  discard block
 block discarded – undo
801 800
  *     true si c'est le cas, false sinon.
802 801
  */
803 802
 function test_espace_prive() {
804
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
803
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
805 804
 }
806 805
 
807 806
 /**
@@ -811,7 +810,7 @@  discard block
 block discarded – undo
811 810
  * @return bool
812 811
  */
813 812
 function test_plugin_actif($plugin) {
814
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
813
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
815 814
 }
816 815
 
817 816
 /**
@@ -842,52 +841,52 @@  discard block
 block discarded – undo
842 841
  *     Texte
843 842
  */
844 843
 function _T($texte, $args = [], $options = []) {
845
-	static $traduire = false;
846
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
847
-	if ($options) {
848
-		// support de l'ancien argument $class
849
-		if (is_string($options)) {
850
-			$options = ['class' => $options];
851
-		}
852
-		$o = array_merge($o, $options);
853
-	}
854
-
855
-	if (!$traduire) {
856
-		$traduire = charger_fonction('traduire', 'inc');
857
-		include_spip('inc/lang');
858
-	}
859
-
860
-	// On peut passer explicitement la langue dans le tableau
861
-	// On utilise le même nom de variable que la globale
862
-	if (isset($args['spip_lang'])) {
863
-		$lang = $args['spip_lang'];
864
-		// On l'enleve pour ne pas le passer au remplacement
865
-		unset($args['spip_lang']);
866
-	} // Sinon on prend la langue du contexte
867
-	else {
868
-		$lang = $GLOBALS['spip_lang'];
869
-	}
870
-	$text = $traduire($texte, $lang);
871
-
872
-	if ($text === null || !strlen($text)) {
873
-		if (!$o['force']) {
874
-			return '';
875
-		}
876
-
877
-		$text = $texte;
878
-
879
-		// pour les chaines non traduites, assurer un service minimum
880
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
881
-			$n = strpos($text, ':');
882
-			if ($n !== false) {
883
-				$text = substr($text, $n + 1);
884
-			}
885
-			$text = str_replace('_', ' ', $text);
886
-		}
887
-		$o['class'] = null;
888
-	}
889
-
890
-	return _L($text, $args, $o);
844
+    static $traduire = false;
845
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
846
+    if ($options) {
847
+        // support de l'ancien argument $class
848
+        if (is_string($options)) {
849
+            $options = ['class' => $options];
850
+        }
851
+        $o = array_merge($o, $options);
852
+    }
853
+
854
+    if (!$traduire) {
855
+        $traduire = charger_fonction('traduire', 'inc');
856
+        include_spip('inc/lang');
857
+    }
858
+
859
+    // On peut passer explicitement la langue dans le tableau
860
+    // On utilise le même nom de variable que la globale
861
+    if (isset($args['spip_lang'])) {
862
+        $lang = $args['spip_lang'];
863
+        // On l'enleve pour ne pas le passer au remplacement
864
+        unset($args['spip_lang']);
865
+    } // Sinon on prend la langue du contexte
866
+    else {
867
+        $lang = $GLOBALS['spip_lang'];
868
+    }
869
+    $text = $traduire($texte, $lang);
870
+
871
+    if ($text === null || !strlen($text)) {
872
+        if (!$o['force']) {
873
+            return '';
874
+        }
875
+
876
+        $text = $texte;
877
+
878
+        // pour les chaines non traduites, assurer un service minimum
879
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
880
+            $n = strpos($text, ':');
881
+            if ($n !== false) {
882
+                $text = substr($text, $n + 1);
883
+            }
884
+            $text = str_replace('_', ' ', $text);
885
+        }
886
+        $o['class'] = null;
887
+    }
888
+
889
+    return _L($text, $args, $o);
891 890
 }
892 891
 
893 892
 
@@ -914,53 +913,53 @@  discard block
 block discarded – undo
914 913
  *     Texte
915 914
  */
916 915
 function _L($text, $args = [], $options = []) {
917
-	$f = $text;
918
-	$defaut_options = [
919
-		'class' => null,
920
-		'sanitize' => true,
921
-	];
922
-	// support de l'ancien argument $class
923
-	if ($options and is_string($options)) {
924
-		$options = ['class' => $options];
925
-	}
926
-	if (is_array($options)) {
927
-		$options += $defaut_options;
928
-	} else {
929
-		$options = $defaut_options;
930
-	}
931
-
932
-	if (is_array($args) and count($args)) {
933
-		if (!function_exists('interdire_scripts')) {
934
-			include_spip('inc/texte');
935
-		}
936
-		if (!function_exists('echapper_html_suspect')) {
937
-			include_spip('inc/texte_mini');
938
-		}
939
-		foreach ($args as $name => $value) {
940
-			if (strpos($text, (string) "@$name@") !== false) {
941
-				if ($options['sanitize']) {
942
-					$value = echapper_html_suspect($value);
943
-					$value = interdire_scripts($value, -1);
944
-				}
945
-				if (!empty($options['class'])) {
946
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
947
-				}
948
-				$text = str_replace("@$name@", $value, $text);
949
-				unset($args[$name]);
950
-			}
951
-		}
952
-		// Si des variables n'ont pas ete inserees, le signaler
953
-		// (chaines de langues pas a jour)
954
-		if ($args) {
955
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
956
-		}
957
-	}
958
-
959
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
960
-		return "<span class='debug-traduction-erreur'>$text</span>";
961
-	} else {
962
-		return $text;
963
-	}
916
+    $f = $text;
917
+    $defaut_options = [
918
+        'class' => null,
919
+        'sanitize' => true,
920
+    ];
921
+    // support de l'ancien argument $class
922
+    if ($options and is_string($options)) {
923
+        $options = ['class' => $options];
924
+    }
925
+    if (is_array($options)) {
926
+        $options += $defaut_options;
927
+    } else {
928
+        $options = $defaut_options;
929
+    }
930
+
931
+    if (is_array($args) and count($args)) {
932
+        if (!function_exists('interdire_scripts')) {
933
+            include_spip('inc/texte');
934
+        }
935
+        if (!function_exists('echapper_html_suspect')) {
936
+            include_spip('inc/texte_mini');
937
+        }
938
+        foreach ($args as $name => $value) {
939
+            if (strpos($text, (string) "@$name@") !== false) {
940
+                if ($options['sanitize']) {
941
+                    $value = echapper_html_suspect($value);
942
+                    $value = interdire_scripts($value, -1);
943
+                }
944
+                if (!empty($options['class'])) {
945
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
946
+                }
947
+                $text = str_replace("@$name@", $value, $text);
948
+                unset($args[$name]);
949
+            }
950
+        }
951
+        // Si des variables n'ont pas ete inserees, le signaler
952
+        // (chaines de langues pas a jour)
953
+        if ($args) {
954
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
955
+        }
956
+    }
957
+
958
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
959
+        return "<span class='debug-traduction-erreur'>$text</span>";
960
+    } else {
961
+        return $text;
962
+    }
964 963
 }
965 964
 
966 965
 
@@ -974,13 +973,13 @@  discard block
 block discarded – undo
974 973
  * @return string
975 974
  */
976 975
 function joli_repertoire($rep) {
977
-	$a = substr($rep, 0, 1);
978
-	if ($a <> '.' and $a <> '/') {
979
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
980
-	}
981
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
976
+    $a = substr($rep, 0, 1);
977
+    if ($a <> '.' and $a <> '/') {
978
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
979
+    }
980
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
982 981
 
983
-	return $rep;
982
+    return $rep;
984 983
 }
985 984
 
986 985
 
@@ -1005,54 +1004,54 @@  discard block
 block discarded – undo
1005 1004
  * @return float|int|string|void
1006 1005
  */
1007 1006
 function spip_timer($t = 'rien', $raw = false) {
1008
-	static $time;
1009
-	$a = time();
1010
-	$b = microtime();
1011
-	// microtime peut contenir les microsecondes et le temps
1012
-	$b = explode(' ', $b);
1013
-	if (count($b) == 2) {
1014
-		$a = end($b);
1015
-	} // plus precis !
1016
-	$b = reset($b);
1017
-	if (!isset($time[$t])) {
1018
-		$time[$t] = $a + $b;
1019
-	} else {
1020
-		$p = ($a + $b - $time[$t]) * 1000;
1021
-		unset($time[$t]);
1007
+    static $time;
1008
+    $a = time();
1009
+    $b = microtime();
1010
+    // microtime peut contenir les microsecondes et le temps
1011
+    $b = explode(' ', $b);
1012
+    if (count($b) == 2) {
1013
+        $a = end($b);
1014
+    } // plus precis !
1015
+    $b = reset($b);
1016
+    if (!isset($time[$t])) {
1017
+        $time[$t] = $a + $b;
1018
+    } else {
1019
+        $p = ($a + $b - $time[$t]) * 1000;
1020
+        unset($time[$t]);
1022 1021
 #			echo "'$p'";exit;
1023
-		if ($raw) {
1024
-			return $p;
1025
-		}
1026
-		if ($p < 1000) {
1027
-			$s = '';
1028
-		} else {
1029
-			$s = sprintf('%d ', $x = floor($p / 1000));
1030
-			$p -= ($x * 1000);
1031
-		}
1022
+        if ($raw) {
1023
+            return $p;
1024
+        }
1025
+        if ($p < 1000) {
1026
+            $s = '';
1027
+        } else {
1028
+            $s = sprintf('%d ', $x = floor($p / 1000));
1029
+            $p -= ($x * 1000);
1030
+        }
1032 1031
 
1033
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1034
-	}
1032
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1033
+    }
1035 1034
 }
1036 1035
 
1037 1036
 
1038 1037
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
1039 1038
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1040 1039
 function spip_touch($fichier, $duree = 0, $touch = true) {
1041
-	if ($duree) {
1042
-		clearstatcache();
1043
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1044
-			return false;
1045
-		}
1046
-	}
1047
-	if ($touch !== false) {
1048
-		if (!@touch($fichier)) {
1049
-			spip_unlink($fichier);
1050
-			@touch($fichier);
1051
-		};
1052
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1053
-	}
1040
+    if ($duree) {
1041
+        clearstatcache();
1042
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1043
+            return false;
1044
+        }
1045
+    }
1046
+    if ($touch !== false) {
1047
+        if (!@touch($fichier)) {
1048
+            spip_unlink($fichier);
1049
+            @touch($fichier);
1050
+        };
1051
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1052
+    }
1054 1053
 
1055
-	return true;
1054
+    return true;
1056 1055
 }
1057 1056
 
1058 1057
 
@@ -1063,11 +1062,11 @@  discard block
 block discarded – undo
1063 1062
  * @uses cron()
1064 1063
  **/
1065 1064
 function action_cron() {
1066
-	include_spip('inc/headers');
1067
-	http_response_code(204); // No Content
1068
-	header('Connection: close');
1069
-	define('_DIRECT_CRON_FORCE', true);
1070
-	cron();
1065
+    include_spip('inc/headers');
1066
+    http_response_code(204); // No Content
1067
+    header('Connection: close');
1068
+    define('_DIRECT_CRON_FORCE', true);
1069
+    cron();
1071 1070
 }
1072 1071
 
1073 1072
 /**
@@ -1083,26 +1082,26 @@  discard block
 block discarded – undo
1083 1082
  *     True si la tache a pu être effectuée
1084 1083
  */
1085 1084
 function cron($taches = [], $taches_old = []) {
1086
-	// si pas en mode cron force, laisser tomber.
1087
-	if (!defined('_DIRECT_CRON_FORCE')) {
1088
-		return false;
1089
-	}
1090
-	if (!is_array($taches)) {
1091
-		$taches = $taches_old;
1092
-	} // compat anciens appels
1093
-	// si taches a inserer en base et base inaccessible, laisser tomber
1094
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1095
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1096
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1097
-	if ($taches and count($taches) and !spip_connect()) {
1098
-		return false;
1099
-	}
1100
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1101
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1102
-		return $genie($taches);
1103
-	}
1104
-
1105
-	return false;
1085
+    // si pas en mode cron force, laisser tomber.
1086
+    if (!defined('_DIRECT_CRON_FORCE')) {
1087
+        return false;
1088
+    }
1089
+    if (!is_array($taches)) {
1090
+        $taches = $taches_old;
1091
+    } // compat anciens appels
1092
+    // si taches a inserer en base et base inaccessible, laisser tomber
1093
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1094
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1095
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1096
+    if ($taches and count($taches) and !spip_connect()) {
1097
+        return false;
1098
+    }
1099
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1100
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1101
+        return $genie($taches);
1102
+    }
1103
+
1104
+    return false;
1106 1105
 }
1107 1106
 
1108 1107
 /**
@@ -1134,17 +1133,17 @@  discard block
 block discarded – undo
1134 1133
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1135 1134
  */
1136 1135
 function job_queue_add(
1137
-	$function,
1138
-	$description,
1139
-	$arguments = [],
1140
-	$file = '',
1141
-	$no_duplicate = false,
1142
-	$time = 0,
1143
-	$priority = 0
1136
+    $function,
1137
+    $description,
1138
+    $arguments = [],
1139
+    $file = '',
1140
+    $no_duplicate = false,
1141
+    $time = 0,
1142
+    $priority = 0
1144 1143
 ) {
1145
-	include_spip('inc/queue');
1144
+    include_spip('inc/queue');
1146 1145
 
1147
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1146
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1148 1147
 }
1149 1148
 
1150 1149
 /**
@@ -1155,9 +1154,9 @@  discard block
 block discarded – undo
1155 1154
  * @return bool
1156 1155
  */
1157 1156
 function job_queue_remove($id_job) {
1158
-	include_spip('inc/queue');
1157
+    include_spip('inc/queue');
1159 1158
 
1160
-	return queue_remove_job($id_job);
1159
+    return queue_remove_job($id_job);
1161 1160
 }
1162 1161
 
1163 1162
 /**
@@ -1170,9 +1169,9 @@  discard block
 block discarded – undo
1170 1169
  *     or an array of simple array to link multiples objet in one time
1171 1170
  */
1172 1171
 function job_queue_link($id_job, $objets) {
1173
-	include_spip('inc/queue');
1172
+    include_spip('inc/queue');
1174 1173
 
1175
-	return queue_link_job($id_job, $objets);
1174
+    return queue_link_job($id_job, $objets);
1176 1175
 }
1177 1176
 
1178 1177
 
@@ -1192,36 +1191,36 @@  discard block
 block discarded – undo
1192 1191
  *  - `null` si la queue n'est pas encore initialisée
1193 1192
  */
1194 1193
 function queue_sleep_time_to_next_job($force = null) {
1195
-	static $queue_next_job_time = -1;
1196
-	if ($force === true) {
1197
-		$queue_next_job_time = -1;
1198
-	} elseif ($force) {
1199
-		$queue_next_job_time = $force;
1200
-	}
1201
-
1202
-	if ($queue_next_job_time == -1) {
1203
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1204
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1205
-		}
1206
-		// utiliser un cache memoire si dispo
1207
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1208
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1209
-		} else {
1210
-			$queue_next_job_time = null;
1211
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1212
-				$queue_next_job_time = intval($contenu);
1213
-			}
1214
-		}
1215
-	}
1216
-
1217
-	if (is_null($queue_next_job_time)) {
1218
-		return null;
1219
-	}
1220
-	if (!$_SERVER['REQUEST_TIME']) {
1221
-		$_SERVER['REQUEST_TIME'] = time();
1222
-	}
1223
-
1224
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1194
+    static $queue_next_job_time = -1;
1195
+    if ($force === true) {
1196
+        $queue_next_job_time = -1;
1197
+    } elseif ($force) {
1198
+        $queue_next_job_time = $force;
1199
+    }
1200
+
1201
+    if ($queue_next_job_time == -1) {
1202
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1203
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1204
+        }
1205
+        // utiliser un cache memoire si dispo
1206
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1207
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1208
+        } else {
1209
+            $queue_next_job_time = null;
1210
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1211
+                $queue_next_job_time = intval($contenu);
1212
+            }
1213
+        }
1214
+    }
1215
+
1216
+    if (is_null($queue_next_job_time)) {
1217
+        return null;
1218
+    }
1219
+    if (!$_SERVER['REQUEST_TIME']) {
1220
+        $_SERVER['REQUEST_TIME'] = time();
1221
+    }
1222
+
1223
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1225 1224
 }
1226 1225
 
1227 1226
 
@@ -1233,11 +1232,11 @@  discard block
 block discarded – undo
1233 1232
  * @return string
1234 1233
  */
1235 1234
 function quote_amp($u) {
1236
-	return preg_replace(
1237
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1238
-		'&amp;',
1239
-		$u
1240
-	);
1235
+    return preg_replace(
1236
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1237
+        '&amp;',
1238
+        $u
1239
+    );
1241 1240
 }
1242 1241
 
1243 1242
 
@@ -1260,27 +1259,27 @@  discard block
 block discarded – undo
1260 1259
  *     Balise HTML `<script>` et son contenu
1261 1260
  **/
1262 1261
 function http_script($script, $src = '', $noscript = '') {
1263
-	static $done = [];
1262
+    static $done = [];
1264 1263
 
1265
-	if ($src && !isset($done[$src])) {
1266
-		$done[$src] = true;
1267
-		$src = find_in_path($src, _JAVASCRIPT);
1268
-		$src = " src='$src'";
1269
-	} else {
1270
-		$src = '';
1271
-	}
1272
-	if ($script) {
1273
-		$script = ("/*<![CDATA[*/\n" .
1274
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1275
-			'/*]]>*/');
1276
-	}
1277
-	if ($noscript) {
1278
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1279
-	}
1264
+    if ($src && !isset($done[$src])) {
1265
+        $done[$src] = true;
1266
+        $src = find_in_path($src, _JAVASCRIPT);
1267
+        $src = " src='$src'";
1268
+    } else {
1269
+        $src = '';
1270
+    }
1271
+    if ($script) {
1272
+        $script = ("/*<![CDATA[*/\n" .
1273
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1274
+            '/*]]>*/');
1275
+    }
1276
+    if ($noscript) {
1277
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1278
+    }
1280 1279
 
1281
-	return ($src or $script or $noscript)
1282
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1283
-		: '';
1280
+    return ($src or $script or $noscript)
1281
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1282
+        : '';
1284 1283
 }
1285 1284
 
1286 1285
 
@@ -1315,7 +1314,7 @@  discard block
 block discarded – undo
1315 1314
  *     Texte échappé
1316 1315
  **/
1317 1316
 function texte_script(string $texte): string {
1318
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1317
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1319 1318
 }
1320 1319
 
1321 1320
 
@@ -1352,68 +1351,68 @@  discard block
 block discarded – undo
1352 1351
  *     Liste des chemins, par ordre de priorité.
1353 1352
  **/
1354 1353
 function _chemin($dir_path = null) {
1355
-	static $path_base = null;
1356
-	static $path_full = null;
1357
-	if ($path_base == null) {
1358
-		// Chemin standard depuis l'espace public
1359
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1360
-			_DIR_RACINE . ':' .
1361
-			_DIR_RACINE . 'squelettes-dist/:' .
1362
-			_DIR_RACINE . 'prive/:' .
1363
-			_DIR_RESTREINT;
1364
-		// Ajouter squelettes/
1365
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1366
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1367
-		}
1368
-		foreach (explode(':', $path) as $dir) {
1369
-			if (strlen($dir) and substr($dir, -1) != '/') {
1370
-				$dir .= '/';
1371
-			}
1372
-			$path_base[] = $dir;
1373
-		}
1374
-		$path_full = $path_base;
1375
-		// Et le(s) dossier(s) des squelettes nommes
1376
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1377
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1378
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1379
-			}
1380
-		}
1381
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1382
-	}
1383
-	if ($dir_path === null) {
1384
-		return $path_full;
1385
-	}
1386
-
1387
-	if (is_array($dir_path) or strlen($dir_path)) {
1388
-		$tete = '';
1389
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1390
-			$tete = array_shift($path_base);
1391
-		}
1392
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1393
-		$dirs = array_reverse($dirs);
1394
-		foreach ($dirs as $dir_path) {
1395
-			if (substr($dir_path, -1) != '/') {
1396
-				$dir_path .= '/';
1397
-			}
1398
-			if (!in_array($dir_path, $path_base)) {
1399
-				array_unshift($path_base, $dir_path);
1400
-			}
1401
-		}
1402
-		if (strlen($tete)) {
1403
-			array_unshift($path_base, $tete);
1404
-		}
1405
-	}
1406
-	$path_full = $path_base;
1407
-	// Et le(s) dossier(s) des squelettes nommes
1408
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1409
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1410
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1411
-		}
1412
-	}
1413
-
1414
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1415
-
1416
-	return $path_full;
1354
+    static $path_base = null;
1355
+    static $path_full = null;
1356
+    if ($path_base == null) {
1357
+        // Chemin standard depuis l'espace public
1358
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1359
+            _DIR_RACINE . ':' .
1360
+            _DIR_RACINE . 'squelettes-dist/:' .
1361
+            _DIR_RACINE . 'prive/:' .
1362
+            _DIR_RESTREINT;
1363
+        // Ajouter squelettes/
1364
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1365
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1366
+        }
1367
+        foreach (explode(':', $path) as $dir) {
1368
+            if (strlen($dir) and substr($dir, -1) != '/') {
1369
+                $dir .= '/';
1370
+            }
1371
+            $path_base[] = $dir;
1372
+        }
1373
+        $path_full = $path_base;
1374
+        // Et le(s) dossier(s) des squelettes nommes
1375
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1376
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1377
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1378
+            }
1379
+        }
1380
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1381
+    }
1382
+    if ($dir_path === null) {
1383
+        return $path_full;
1384
+    }
1385
+
1386
+    if (is_array($dir_path) or strlen($dir_path)) {
1387
+        $tete = '';
1388
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1389
+            $tete = array_shift($path_base);
1390
+        }
1391
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1392
+        $dirs = array_reverse($dirs);
1393
+        foreach ($dirs as $dir_path) {
1394
+            if (substr($dir_path, -1) != '/') {
1395
+                $dir_path .= '/';
1396
+            }
1397
+            if (!in_array($dir_path, $path_base)) {
1398
+                array_unshift($path_base, $dir_path);
1399
+            }
1400
+        }
1401
+        if (strlen($tete)) {
1402
+            array_unshift($path_base, $tete);
1403
+        }
1404
+    }
1405
+    $path_full = $path_base;
1406
+    // Et le(s) dossier(s) des squelettes nommes
1407
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1408
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1409
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1410
+        }
1411
+    }
1412
+
1413
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1414
+
1415
+    return $path_full;
1417 1416
 }
1418 1417
 
1419 1418
 /**
@@ -1426,78 +1425,78 @@  discard block
 block discarded – undo
1426 1425
  * @return array Liste de chemins
1427 1426
  **/
1428 1427
 function creer_chemin() {
1429
-	$path_a = _chemin();
1430
-	static $c = '';
1428
+    $path_a = _chemin();
1429
+    static $c = '';
1431 1430
 
1432
-	// on calcule le chemin si le dossier skel a change
1433
-	if ($c != $GLOBALS['dossier_squelettes']) {
1434
-		// assurer le non plantage lors de la montee de version :
1435
-		$c = $GLOBALS['dossier_squelettes'];
1436
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1437
-	}
1431
+    // on calcule le chemin si le dossier skel a change
1432
+    if ($c != $GLOBALS['dossier_squelettes']) {
1433
+        // assurer le non plantage lors de la montee de version :
1434
+        $c = $GLOBALS['dossier_squelettes'];
1435
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1436
+    }
1438 1437
 
1439
-	return $path_a;
1438
+    return $path_a;
1440 1439
 }
1441 1440
 
1442 1441
 
1443 1442
 function lister_themes_prives() {
1444
-	static $themes = null;
1445
-	if (is_null($themes)) {
1446
-		// si pas encore definie
1447
-		if (!defined('_SPIP_THEME_PRIVE')) {
1448
-			define('_SPIP_THEME_PRIVE', 'spip');
1449
-		}
1450
-		$themes = [_SPIP_THEME_PRIVE];
1451
-		// lors d'une installation neuve, prefs n'est pas definie.
1452
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1453
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1454
-		} else {
1455
-			$prefs = [];
1456
-		}
1457
-		if (is_string($prefs)) {
1458
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1459
-		}
1460
-		if (
1461
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1462
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1463
-			and $theme != _SPIP_THEME_PRIVE
1464
-		) {
1465
-			array_unshift($themes, $theme);
1466
-		} // placer le theme choisi en tete
1467
-	}
1468
-
1469
-	return $themes;
1443
+    static $themes = null;
1444
+    if (is_null($themes)) {
1445
+        // si pas encore definie
1446
+        if (!defined('_SPIP_THEME_PRIVE')) {
1447
+            define('_SPIP_THEME_PRIVE', 'spip');
1448
+        }
1449
+        $themes = [_SPIP_THEME_PRIVE];
1450
+        // lors d'une installation neuve, prefs n'est pas definie.
1451
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1452
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1453
+        } else {
1454
+            $prefs = [];
1455
+        }
1456
+        if (is_string($prefs)) {
1457
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1458
+        }
1459
+        if (
1460
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1461
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1462
+            and $theme != _SPIP_THEME_PRIVE
1463
+        ) {
1464
+            array_unshift($themes, $theme);
1465
+        } // placer le theme choisi en tete
1466
+    }
1467
+
1468
+    return $themes;
1470 1469
 }
1471 1470
 
1472 1471
 function find_in_theme($file, $subdir = '', $include = false) {
1473
-	static $themefiles = [];
1474
-	if (isset($themefiles["$subdir$file"])) {
1475
-		return $themefiles["$subdir$file"];
1476
-	}
1477
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1478
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1479
-	if (
1480
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1481
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1482
-		and $f = find_in_theme("$file_svg_generique")
1483
-	) {
1484
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1485
-			return $themefiles["$subdir$file"] = $fsize;
1486
-		}
1487
-		else {
1488
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1489
-		}
1490
-	}
1491
-
1492
-	$themes = lister_themes_prives();
1493
-	foreach ($themes as $theme) {
1494
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1495
-			return $themefiles["$subdir$file"] = $f;
1496
-		}
1497
-	}
1498
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1499
-
1500
-	return $themefiles["$subdir$file"] = '';
1472
+    static $themefiles = [];
1473
+    if (isset($themefiles["$subdir$file"])) {
1474
+        return $themefiles["$subdir$file"];
1475
+    }
1476
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1477
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1478
+    if (
1479
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1480
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1481
+        and $f = find_in_theme("$file_svg_generique")
1482
+    ) {
1483
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1484
+            return $themefiles["$subdir$file"] = $fsize;
1485
+        }
1486
+        else {
1487
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1488
+        }
1489
+    }
1490
+
1491
+    $themes = lister_themes_prives();
1492
+    foreach ($themes as $theme) {
1493
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1494
+            return $themefiles["$subdir$file"] = $f;
1495
+        }
1496
+    }
1497
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1498
+
1499
+    return $themefiles["$subdir$file"] = '';
1501 1500
 }
1502 1501
 
1503 1502
 
@@ -1521,31 +1520,31 @@  discard block
 block discarded – undo
1521 1520
  *     sinon chaîne vide.
1522 1521
  **/
1523 1522
 function chemin_image($icone) {
1524
-	static $icone_renommer;
1525
-	if ($p = strpos($icone, '?')) {
1526
-		$icone = substr($icone, 0, $p);
1527
-	}
1528
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1529
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1530
-		return $icone;
1531
-	}
1532
-
1533
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1534
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1535
-		return $f;
1536
-	}
1537
-	// sinon passer par le module de renommage
1538
-	if (is_null($icone_renommer)) {
1539
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1540
-	}
1541
-	if ($icone_renommer) {
1542
-		[$icone, $fonction] = $icone_renommer($icone, '');
1543
-		if (file_exists($icone)) {
1544
-			return $icone;
1545
-		}
1546
-	}
1547
-
1548
-	return find_in_path($icone, _NOM_IMG_PACK);
1523
+    static $icone_renommer;
1524
+    if ($p = strpos($icone, '?')) {
1525
+        $icone = substr($icone, 0, $p);
1526
+    }
1527
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1528
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1529
+        return $icone;
1530
+    }
1531
+
1532
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1533
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1534
+        return $f;
1535
+    }
1536
+    // sinon passer par le module de renommage
1537
+    if (is_null($icone_renommer)) {
1538
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1539
+    }
1540
+    if ($icone_renommer) {
1541
+        [$icone, $fonction] = $icone_renommer($icone, '');
1542
+        if (file_exists($icone)) {
1543
+            return $icone;
1544
+        }
1545
+    }
1546
+
1547
+    return find_in_path($icone, _NOM_IMG_PACK);
1549 1548
 }
1550 1549
 
1551 1550
 //
@@ -1583,128 +1582,128 @@  discard block
 block discarded – undo
1583 1582
  *     - false : fichier introuvable
1584 1583
  **/
1585 1584
 function find_in_path($file, $dirname = '', $include = false) {
1586
-	static $dirs = [];
1587
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1588
-	static $c = '';
1589
-
1590
-	if (!$file and !strlen($file)) {
1591
-		return false;
1592
-	}
1593
-
1594
-	// on calcule le chemin si le dossier skel a change
1595
-	if ($c != $GLOBALS['dossier_squelettes']) {
1596
-		// assurer le non plantage lors de la montee de version :
1597
-		$c = $GLOBALS['dossier_squelettes'];
1598
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1599
-	}
1600
-
1601
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1602
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1603
-			return false;
1604
-		}
1605
-		if ($include and !isset($inc[$dirname][$file])) {
1606
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1608
-		}
1609
-
1610
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1611
-	}
1612
-
1613
-	$a = strrpos($file, '/');
1614
-	if ($a !== false) {
1615
-		$dirname .= substr($file, 0, ++$a);
1616
-		$file = substr($file, $a);
1617
-	}
1618
-
1619
-	foreach (creer_chemin() as $dir) {
1620
-		if (!isset($dirs[$a = $dir . $dirname])) {
1621
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1622
-		}
1623
-		if ($dirs[$a]) {
1624
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1625
-				if ($include and !isset($inc[$dirname][$file])) {
1626
-					include_once _ROOT_CWD . $a;
1627
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1628
-				}
1629
-				if (!defined('_SAUVER_CHEMIN')) {
1630
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1631
-					if (is_null($GLOBALS['path_files'])) {
1632
-						return $a;
1633
-					}
1634
-					define('_SAUVER_CHEMIN', true);
1635
-				}
1636
-
1637
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1638
-			}
1639
-		}
1640
-	}
1641
-
1642
-	if ($include) {
1643
-		spip_log("include_spip $dirname$file non trouve");
1644
-		if ($include === 'required') {
1645
-			echo '<pre>',
1646
-			'<strong>Erreur Fatale</strong><br />';
1647
-			if (function_exists('debug_print_backtrace')) {
1648
-				echo debug_print_backtrace();
1649
-			}
1650
-			echo '</pre>';
1651
-			die("Erreur interne: ne peut inclure $dirname$file");
1652
-		}
1653
-	}
1654
-
1655
-	if (!defined('_SAUVER_CHEMIN')) {
1656
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1657
-		if (is_null($GLOBALS['path_files'])) {
1658
-			return false;
1659
-		}
1660
-		define('_SAUVER_CHEMIN', true);
1661
-	}
1662
-
1663
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1585
+    static $dirs = [];
1586
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1587
+    static $c = '';
1588
+
1589
+    if (!$file and !strlen($file)) {
1590
+        return false;
1591
+    }
1592
+
1593
+    // on calcule le chemin si le dossier skel a change
1594
+    if ($c != $GLOBALS['dossier_squelettes']) {
1595
+        // assurer le non plantage lors de la montee de version :
1596
+        $c = $GLOBALS['dossier_squelettes'];
1597
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1598
+    }
1599
+
1600
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1601
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1602
+            return false;
1603
+        }
1604
+        if ($include and !isset($inc[$dirname][$file])) {
1605
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1606
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1607
+        }
1608
+
1609
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1610
+    }
1611
+
1612
+    $a = strrpos($file, '/');
1613
+    if ($a !== false) {
1614
+        $dirname .= substr($file, 0, ++$a);
1615
+        $file = substr($file, $a);
1616
+    }
1617
+
1618
+    foreach (creer_chemin() as $dir) {
1619
+        if (!isset($dirs[$a = $dir . $dirname])) {
1620
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1621
+        }
1622
+        if ($dirs[$a]) {
1623
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1624
+                if ($include and !isset($inc[$dirname][$file])) {
1625
+                    include_once _ROOT_CWD . $a;
1626
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1627
+                }
1628
+                if (!defined('_SAUVER_CHEMIN')) {
1629
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1630
+                    if (is_null($GLOBALS['path_files'])) {
1631
+                        return $a;
1632
+                    }
1633
+                    define('_SAUVER_CHEMIN', true);
1634
+                }
1635
+
1636
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1637
+            }
1638
+        }
1639
+    }
1640
+
1641
+    if ($include) {
1642
+        spip_log("include_spip $dirname$file non trouve");
1643
+        if ($include === 'required') {
1644
+            echo '<pre>',
1645
+            '<strong>Erreur Fatale</strong><br />';
1646
+            if (function_exists('debug_print_backtrace')) {
1647
+                echo debug_print_backtrace();
1648
+            }
1649
+            echo '</pre>';
1650
+            die("Erreur interne: ne peut inclure $dirname$file");
1651
+        }
1652
+    }
1653
+
1654
+    if (!defined('_SAUVER_CHEMIN')) {
1655
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1656
+        if (is_null($GLOBALS['path_files'])) {
1657
+            return false;
1658
+        }
1659
+        define('_SAUVER_CHEMIN', true);
1660
+    }
1661
+
1662
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1664 1663
 }
1665 1664
 
1666 1665
 function clear_path_cache() {
1667
-	$GLOBALS['path_files'] = [];
1668
-	spip_unlink(_CACHE_CHEMIN);
1666
+    $GLOBALS['path_files'] = [];
1667
+    spip_unlink(_CACHE_CHEMIN);
1669 1668
 }
1670 1669
 
1671 1670
 function load_path_cache() {
1672
-	// charger le path des plugins
1673
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1674
-		include_once(_CACHE_PLUGINS_PATH);
1675
-	}
1676
-	$GLOBALS['path_files'] = [];
1677
-	// si le visiteur est admin,
1678
-	// on ne recharge pas le cache pour forcer sa mise a jour
1679
-	if (
1680
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1681
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1682
-		// utiliser le cookie est un pis aller qui marche 'en general'
1683
-		// on blinde par un second test au moment de la lecture de la session
1684
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1685
-		// et en ignorant ce cache en cas de recalcul explicite
1686
-		!_request('var_mode')
1687
-	) {
1688
-		// on essaye de lire directement sans verrou pour aller plus vite
1689
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1690
-			// mais si semble corrompu on relit avec un verrou
1691
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1692
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1693
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1694
-					$GLOBALS['path_files'] = [];
1695
-				}
1696
-			}
1697
-		}
1698
-	}
1671
+    // charger le path des plugins
1672
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1673
+        include_once(_CACHE_PLUGINS_PATH);
1674
+    }
1675
+    $GLOBALS['path_files'] = [];
1676
+    // si le visiteur est admin,
1677
+    // on ne recharge pas le cache pour forcer sa mise a jour
1678
+    if (
1679
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1680
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1681
+        // utiliser le cookie est un pis aller qui marche 'en general'
1682
+        // on blinde par un second test au moment de la lecture de la session
1683
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1684
+        // et en ignorant ce cache en cas de recalcul explicite
1685
+        !_request('var_mode')
1686
+    ) {
1687
+        // on essaye de lire directement sans verrou pour aller plus vite
1688
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1689
+            // mais si semble corrompu on relit avec un verrou
1690
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1691
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1692
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1693
+                    $GLOBALS['path_files'] = [];
1694
+                }
1695
+            }
1696
+        }
1697
+    }
1699 1698
 }
1700 1699
 
1701 1700
 function save_path_cache() {
1702
-	if (
1703
-		defined('_SAUVER_CHEMIN')
1704
-		and _SAUVER_CHEMIN
1705
-	) {
1706
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1707
-	}
1701
+    if (
1702
+        defined('_SAUVER_CHEMIN')
1703
+        and _SAUVER_CHEMIN
1704
+    ) {
1705
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1706
+    }
1708 1707
 }
1709 1708
 
1710 1709
 
@@ -1724,33 +1723,33 @@  discard block
 block discarded – undo
1724 1723
  * @return array
1725 1724
  */
1726 1725
 function find_all_in_path($dir, $pattern, $recurs = false) {
1727
-	$liste_fichiers = [];
1728
-	$maxfiles = 10000;
1729
-
1730
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1731
-	// on a pas encore inclus flock.php
1732
-	if (!function_exists('preg_files')) {
1733
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1734
-	}
1735
-
1736
-	// Parcourir le chemin
1737
-	foreach (creer_chemin() as $d) {
1738
-		$f = $d . $dir;
1739
-		if (@is_dir($f)) {
1740
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1741
-			foreach ($liste as $chemin) {
1742
-				$nom = basename($chemin);
1743
-				// ne prendre que les fichiers pas deja trouves
1744
-				// car find_in_path prend le premier qu'il trouve,
1745
-				// les autres sont donc masques
1746
-				if (!isset($liste_fichiers[$nom])) {
1747
-					$liste_fichiers[$nom] = $chemin;
1748
-				}
1749
-			}
1750
-		}
1751
-	}
1752
-
1753
-	return $liste_fichiers;
1726
+    $liste_fichiers = [];
1727
+    $maxfiles = 10000;
1728
+
1729
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1730
+    // on a pas encore inclus flock.php
1731
+    if (!function_exists('preg_files')) {
1732
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1733
+    }
1734
+
1735
+    // Parcourir le chemin
1736
+    foreach (creer_chemin() as $d) {
1737
+        $f = $d . $dir;
1738
+        if (@is_dir($f)) {
1739
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1740
+            foreach ($liste as $chemin) {
1741
+                $nom = basename($chemin);
1742
+                // ne prendre que les fichiers pas deja trouves
1743
+                // car find_in_path prend le premier qu'il trouve,
1744
+                // les autres sont donc masques
1745
+                if (!isset($liste_fichiers[$nom])) {
1746
+                    $liste_fichiers[$nom] = $chemin;
1747
+                }
1748
+            }
1749
+        }
1750
+    }
1751
+
1752
+    return $liste_fichiers;
1754 1753
 }
1755 1754
 
1756 1755
 /**
@@ -1762,17 +1761,17 @@  discard block
 block discarded – undo
1762 1761
  * @return bool
1763 1762
  */
1764 1763
 function autoriser_sans_cookie($nom, $strict = false) {
1765
-	static $autsanscookie = ['install', 'base_repair'];
1764
+    static $autsanscookie = ['install', 'base_repair'];
1766 1765
 
1767
-	if (in_array($nom, $autsanscookie)) {
1768
-		if (test_espace_prive()) {
1769
-			include_spip('base/connect_sql');
1770
-			if (!$strict or !spip_connect()) {
1771
-				return true;
1772
-			}
1773
-		}
1774
-	}
1775
-	return false;
1766
+    if (in_array($nom, $autsanscookie)) {
1767
+        if (test_espace_prive()) {
1768
+            include_spip('base/connect_sql');
1769
+            if (!$strict or !spip_connect()) {
1770
+                return true;
1771
+            }
1772
+        }
1773
+    }
1774
+    return false;
1776 1775
 }
1777 1776
 
1778 1777
 /**
@@ -1782,60 +1781,60 @@  discard block
 block discarded – undo
1782 1781
  * @return string
1783 1782
  */
1784 1783
 function charger_fonction_url(string $quoi, string $type = '') {
1785
-	if ($type === 'defaut') {
1786
-		$objet = objet_type($quoi);
1787
-		if (
1788
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1789
-			// deprecated
1790
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1791
-		) {
1792
-			return $f;
1793
-		}
1794
-		return '';
1795
-	}
1796
-
1797
-	$url_type = $type;
1798
-	if (!$url_type) {
1799
-		$url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1800
-	}
1801
-
1802
-	// inclure le module d'url
1803
-	include_spip('urls/' . $url_type);
1804
-
1805
-	switch ($quoi) {
1806
-		case 'page':
1807
-			if (
1808
-				 function_exists($f = "urls_{$url_type}_generer_url_page")
1809
-				or function_exists($f .= '_dist')
1810
-				// ou une fonction custom utilisateur independante du type d'url
1811
-				or function_exists($f = 'generer_url_page')
1812
-				or function_exists($f .= '_dist')
1813
-			) {
1814
-				return $f;
1815
-			}
1816
-			// pas de compat ancienne version ici, c'est une nouvelle feature
1817
-			return '';
1818
-		case 'objet':
1819
-		case 'decoder':
1820
-		default:
1821
-			$fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1822
-			if (
1823
-				function_exists($f = "urls_{$url_type}_{$fquoi}")
1824
-				or function_exists($f .= '_dist')
1825
-			) {
1826
-				return $f;
1827
-			}
1828
-			// est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1829
-			// c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1830
-			if ($f = charger_fonction($url_type, 'urls', true)) {
1831
-				return $f;
1832
-			}
1833
-			// sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1834
-			if (!$type and $url_type !== 'page') {
1835
-				return charger_fonction_url($quoi, 'page');
1836
-			}
1837
-			return '';
1838
-	}
1784
+    if ($type === 'defaut') {
1785
+        $objet = objet_type($quoi);
1786
+        if (
1787
+            $f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1788
+            // deprecated
1789
+            or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1790
+        ) {
1791
+            return $f;
1792
+        }
1793
+        return '';
1794
+    }
1795
+
1796
+    $url_type = $type;
1797
+    if (!$url_type) {
1798
+        $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1799
+    }
1800
+
1801
+    // inclure le module d'url
1802
+    include_spip('urls/' . $url_type);
1803
+
1804
+    switch ($quoi) {
1805
+        case 'page':
1806
+            if (
1807
+                    function_exists($f = "urls_{$url_type}_generer_url_page")
1808
+                or function_exists($f .= '_dist')
1809
+                // ou une fonction custom utilisateur independante du type d'url
1810
+                or function_exists($f = 'generer_url_page')
1811
+                or function_exists($f .= '_dist')
1812
+            ) {
1813
+                return $f;
1814
+            }
1815
+            // pas de compat ancienne version ici, c'est une nouvelle feature
1816
+            return '';
1817
+        case 'objet':
1818
+        case 'decoder':
1819
+        default:
1820
+            $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1821
+            if (
1822
+                function_exists($f = "urls_{$url_type}_{$fquoi}")
1823
+                or function_exists($f .= '_dist')
1824
+            ) {
1825
+                return $f;
1826
+            }
1827
+            // est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1828
+            // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1829
+            if ($f = charger_fonction($url_type, 'urls', true)) {
1830
+                return $f;
1831
+            }
1832
+            // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1833
+            if (!$type and $url_type !== 'page') {
1834
+                return charger_fonction_url($quoi, 'page');
1835
+            }
1836
+            return '';
1837
+    }
1839 1838
 }
1840 1839
 
1841 1840
 
@@ -1862,48 +1861,48 @@  discard block
 block discarded – undo
1862 1861
  *   url codee ou fonction de decodage
1863 1862
  */
1864 1863
 function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1865
-	if ($public === null) {
1866
-		$public = !test_espace_prive();
1867
-	}
1868
-	$id = intval($id);
1869
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1870
-
1871
-	if (!$public) {
1872
-		if (!$entite) {
1873
-			return '';
1874
-		}
1875
-		if (!function_exists('generer_objet_url_ecrire')) {
1876
-			include_spip('inc/urls');
1877
-		}
1878
-		$res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1879
-	} else {
1880
-		$f = charger_fonction_url('objet', $type ?? '');
1881
-
1882
-		// @deprecated si $entite='', on veut la fonction de passage URL ==> id
1883
-		// @see charger_fonction_url
1884
-		if (!$entite) {
1885
-			return $f;
1886
-		}
1887
-
1888
-		// mais d'abord il faut tester le cas des urls sur une
1889
-		// base distante
1890
-		if (
1891
-			$connect
1892
-			and $g = charger_fonction('connect', 'urls', true)
1893
-		) {
1894
-			$f = $g;
1895
-		}
1896
-
1897
-		$res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1898
-	}
1899
-	if ($res) {
1900
-		return $res;
1901
-	}
1902
-
1903
-	// On a ete gentil mais la ....
1904
-	spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1905
-
1906
-	return '';
1864
+    if ($public === null) {
1865
+        $public = !test_espace_prive();
1866
+    }
1867
+    $id = intval($id);
1868
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1869
+
1870
+    if (!$public) {
1871
+        if (!$entite) {
1872
+            return '';
1873
+        }
1874
+        if (!function_exists('generer_objet_url_ecrire')) {
1875
+            include_spip('inc/urls');
1876
+        }
1877
+        $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1878
+    } else {
1879
+        $f = charger_fonction_url('objet', $type ?? '');
1880
+
1881
+        // @deprecated si $entite='', on veut la fonction de passage URL ==> id
1882
+        // @see charger_fonction_url
1883
+        if (!$entite) {
1884
+            return $f;
1885
+        }
1886
+
1887
+        // mais d'abord il faut tester le cas des urls sur une
1888
+        // base distante
1889
+        if (
1890
+            $connect
1891
+            and $g = charger_fonction('connect', 'urls', true)
1892
+        ) {
1893
+            $f = $g;
1894
+        }
1895
+
1896
+        $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1897
+    }
1898
+    if ($res) {
1899
+        return $res;
1900
+    }
1901
+
1902
+    // On a ete gentil mais la ....
1903
+    spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1904
+
1905
+    return '';
1907 1906
 }
1908 1907
 
1909 1908
 /**
@@ -1911,10 +1910,10 @@  discard block
 block discarded – undo
1911 1910
  * @see generer_objet_url
1912 1911
  */
1913 1912
 function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1914
-	if ($public and is_string($public)) {
1915
-		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1916
-	}
1917
-	return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1913
+    if ($public and is_string($public)) {
1914
+        return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1915
+    }
1916
+    return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1918 1917
 }
1919 1918
 
1920 1919
 /**
@@ -1926,19 +1925,19 @@  discard block
 block discarded – undo
1926 1925
  * @return string
1927 1926
  */
1928 1927
 function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string {
1929
-	$id = intval($id);
1930
-	$exec = objet_info($entite, 'url_edit');
1931
-	$url = generer_url_ecrire($exec, $args);
1932
-	if (intval($id)) {
1933
-		$url = parametre_url($url, id_table_objet($entite), $id);
1934
-	} else {
1935
-		$url = parametre_url($url, 'new', 'oui');
1936
-	}
1937
-	if ($ancre) {
1938
-		$url = ancre_url($url, $ancre);
1939
-	}
1928
+    $id = intval($id);
1929
+    $exec = objet_info($entite, 'url_edit');
1930
+    $url = generer_url_ecrire($exec, $args);
1931
+    if (intval($id)) {
1932
+        $url = parametre_url($url, id_table_objet($entite), $id);
1933
+    } else {
1934
+        $url = parametre_url($url, 'new', 'oui');
1935
+    }
1936
+    if ($ancre) {
1937
+        $url = ancre_url($url, $ancre);
1938
+    }
1940 1939
 
1941
-	return $url;
1940
+    return $url;
1942 1941
 }
1943 1942
 
1944 1943
 /**
@@ -1946,18 +1945,18 @@  discard block
 block discarded – undo
1946 1945
  * @see generer_objet_url_ecrire_edit
1947 1946
  */
1948 1947
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1949
-	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1948
+    return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1950 1949
 }
1951 1950
 
1952 1951
 
1953 1952
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1954
-	include_spip('base/connect_sql');
1955
-	$id_type = id_table_objet($entite, $public);
1953
+    include_spip('base/connect_sql');
1954
+    $id_type = id_table_objet($entite, $public);
1956 1955
 
1957
-	return _DIR_RACINE . get_spip_script('./')
1958
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1959
-	. (!$args ? '' : "&$args")
1960
-	. (!$ancre ? '' : "#$ancre");
1956
+    return _DIR_RACINE . get_spip_script('./')
1957
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1958
+    . (!$args ? '' : "&$args")
1959
+    . (!$ancre ? '' : "#$ancre");
1961 1960
 }
1962 1961
 
1963 1962
 
@@ -1968,18 +1967,18 @@  discard block
 block discarded – undo
1968 1967
  * @return string
1969 1968
  */
1970 1969
 function urlencode_1738($url) {
1971
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1972
-		$uri = '';
1973
-		for ($i = 0; $i < strlen($url); $i++) {
1974
-			if (ord($a = $url[$i]) > 127) {
1975
-				$a = rawurlencode($a);
1976
-			}
1977
-			$uri .= $a;
1978
-		}
1979
-		$url = $uri;
1980
-	}
1970
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1971
+        $uri = '';
1972
+        for ($i = 0; $i < strlen($url); $i++) {
1973
+            if (ord($a = $url[$i]) > 127) {
1974
+                $a = rawurlencode($a);
1975
+            }
1976
+            $uri .= $a;
1977
+        }
1978
+        $url = $uri;
1979
+    }
1981 1980
 
1982
-	return quote_amp($url);
1981
+    return quote_amp($url);
1983 1982
 }
1984 1983
 
1985 1984
 /**
@@ -1995,14 +1994,14 @@  discard block
 block discarded – undo
1995 1994
  * @return string
1996 1995
  */
1997 1996
 function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1998
-	$id = intval($id);
1999
-	$h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
2000
-	if (!preg_match(',^\w+:,', $h)) {
2001
-		include_spip('inc/filtres_mini');
2002
-		$h = url_absolue($h);
2003
-	}
1997
+    $id = intval($id);
1998
+    $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
1999
+    if (!preg_match(',^\w+:,', $h)) {
2000
+        include_spip('inc/filtres_mini');
2001
+        $h = url_absolue($h);
2002
+    }
2004 2003
 
2005
-	return $h;
2004
+    return $h;
2006 2005
 }
2007 2006
 
2008 2007
 /**
@@ -2010,7 +2009,7 @@  discard block
 block discarded – undo
2010 2009
  * @see  generer_objet_url_absolue
2011 2010
  */
2012 2011
 function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) {
2013
-	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
2012
+    return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
2014 2013
 }
2015 2014
 
2016 2015
 
@@ -2026,11 +2025,11 @@  discard block
 block discarded – undo
2026 2025
  *     true si la valeur est considérée active ; false sinon.
2027 2026
  **/
2028 2027
 function test_valeur_serveur($truc) {
2029
-	if (!$truc) {
2030
-		return false;
2031
-	}
2028
+    if (!$truc) {
2029
+        return false;
2030
+    }
2032 2031
 
2033
-	return (strtolower($truc) !== 'off');
2032
+    return (strtolower($truc) !== 'off');
2034 2033
 }
2035 2034
 
2036 2035
 //
@@ -2058,89 +2057,89 @@  discard block
 block discarded – undo
2058 2057
  */
2059 2058
 function url_de_base($profondeur = null) {
2060 2059
 
2061
-	static $url = [];
2062
-	if (is_array($profondeur)) {
2063
-		return $url = $profondeur;
2064
-	}
2065
-	if ($profondeur === false) {
2066
-		return $url;
2067
-	}
2068
-
2069
-	if (is_null($profondeur)) {
2070
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2071
-	}
2072
-
2073
-	if (isset($url[$profondeur])) {
2074
-		return $url[$profondeur];
2075
-	}
2076
-
2077
-	$http = 'http';
2078
-
2079
-	if (
2080
-		isset($_SERVER['SCRIPT_URI'])
2081
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2082
-	) {
2083
-		$http = 'https';
2084
-	} elseif (
2085
-		isset($_SERVER['HTTPS'])
2086
-		and test_valeur_serveur($_SERVER['HTTPS'])
2087
-	) {
2088
-		$http = 'https';
2089
-	}
2090
-
2091
-	// note : HTTP_HOST contient le :port si necessaire
2092
-	if ($host = $_SERVER['HTTP_HOST'] ?? null) {
2093
-		// Filtrer $host pour proteger d'attaques d'entete HTTP
2094
-		$host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
2095
-	}
2096
-
2097
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2098
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2099
-		$host = $GLOBALS['meta']['adresse_site'];
2100
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2101
-			$http = $scheme;
2102
-			$host = str_replace("{$scheme}://", '', $host);
2103
-		}
2104
-	}
2105
-	if (
2106
-		isset($_SERVER['SERVER_PORT'])
2107
-		and $port = $_SERVER['SERVER_PORT']
2108
-		and strpos($host, ':') == false
2109
-	) {
2110
-		if (!defined('_PORT_HTTP_STANDARD')) {
2111
-			define('_PORT_HTTP_STANDARD', '80');
2112
-		}
2113
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2114
-			define('_PORT_HTTPS_STANDARD', '443');
2115
-		}
2116
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2117
-			$host .= ":$port";
2118
-		}
2119
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2120
-			$host .= ":$port";
2121
-		}
2122
-	}
2123
-
2124
-	if (!$GLOBALS['REQUEST_URI']) {
2125
-		if (isset($_SERVER['REQUEST_URI'])) {
2126
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2127
-		} else {
2128
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2129
-			if (
2130
-				!empty($_SERVER['QUERY_STRING'])
2131
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2132
-			) {
2133
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2134
-			}
2135
-		}
2136
-	}
2137
-
2138
-	// Et nettoyer l'url
2139
-	$GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
2140
-
2141
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2142
-
2143
-	return $url[$profondeur];
2060
+    static $url = [];
2061
+    if (is_array($profondeur)) {
2062
+        return $url = $profondeur;
2063
+    }
2064
+    if ($profondeur === false) {
2065
+        return $url;
2066
+    }
2067
+
2068
+    if (is_null($profondeur)) {
2069
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2070
+    }
2071
+
2072
+    if (isset($url[$profondeur])) {
2073
+        return $url[$profondeur];
2074
+    }
2075
+
2076
+    $http = 'http';
2077
+
2078
+    if (
2079
+        isset($_SERVER['SCRIPT_URI'])
2080
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2081
+    ) {
2082
+        $http = 'https';
2083
+    } elseif (
2084
+        isset($_SERVER['HTTPS'])
2085
+        and test_valeur_serveur($_SERVER['HTTPS'])
2086
+    ) {
2087
+        $http = 'https';
2088
+    }
2089
+
2090
+    // note : HTTP_HOST contient le :port si necessaire
2091
+    if ($host = $_SERVER['HTTP_HOST'] ?? null) {
2092
+        // Filtrer $host pour proteger d'attaques d'entete HTTP
2093
+        $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
2094
+    }
2095
+
2096
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2097
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2098
+        $host = $GLOBALS['meta']['adresse_site'];
2099
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2100
+            $http = $scheme;
2101
+            $host = str_replace("{$scheme}://", '', $host);
2102
+        }
2103
+    }
2104
+    if (
2105
+        isset($_SERVER['SERVER_PORT'])
2106
+        and $port = $_SERVER['SERVER_PORT']
2107
+        and strpos($host, ':') == false
2108
+    ) {
2109
+        if (!defined('_PORT_HTTP_STANDARD')) {
2110
+            define('_PORT_HTTP_STANDARD', '80');
2111
+        }
2112
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2113
+            define('_PORT_HTTPS_STANDARD', '443');
2114
+        }
2115
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2116
+            $host .= ":$port";
2117
+        }
2118
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2119
+            $host .= ":$port";
2120
+        }
2121
+    }
2122
+
2123
+    if (!$GLOBALS['REQUEST_URI']) {
2124
+        if (isset($_SERVER['REQUEST_URI'])) {
2125
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2126
+        } else {
2127
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2128
+            if (
2129
+                !empty($_SERVER['QUERY_STRING'])
2130
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2131
+            ) {
2132
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2133
+            }
2134
+        }
2135
+    }
2136
+
2137
+    // Et nettoyer l'url
2138
+    $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
2139
+
2140
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2141
+
2142
+    return $url[$profondeur];
2144 2143
 }
2145 2144
 
2146 2145
 /**
@@ -2153,26 +2152,26 @@  discard block
 block discarded – undo
2153 2152
  * @return string
2154 2153
  */
2155 2154
 function url_de_($http, $host, $request, $prof = 0) {
2156
-	$prof = max($prof, 0);
2155
+    $prof = max($prof, 0);
2157 2156
 
2158
-	$myself = ltrim($request, '/');
2159
-	# supprimer la chaine de GET
2160
-	[$myself] = explode('?', $myself);
2161
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2162
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2163
-	if (strpos($myself, '://') !== false) {
2164
-		$myself = explode('://', $myself);
2165
-		array_shift($myself);
2166
-		$myself = implode('://', $myself);
2167
-		$myself = explode('/', $myself);
2168
-		array_shift($myself);
2169
-		$myself = implode('/', $myself);
2170
-	}
2171
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2157
+    $myself = ltrim($request, '/');
2158
+    # supprimer la chaine de GET
2159
+    [$myself] = explode('?', $myself);
2160
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2161
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2162
+    if (strpos($myself, '://') !== false) {
2163
+        $myself = explode('://', $myself);
2164
+        array_shift($myself);
2165
+        $myself = implode('://', $myself);
2166
+        $myself = explode('/', $myself);
2167
+        array_shift($myself);
2168
+        $myself = implode('/', $myself);
2169
+    }
2170
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2172 2171
 
2173
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2172
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2174 2173
 
2175
-	return $url;
2174
+    return $url;
2176 2175
 }
2177 2176
 
2178 2177
 
@@ -2207,26 +2206,26 @@  discard block
 block discarded – undo
2207 2206
  * @return string URL
2208 2207
  **/
2209 2208
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2210
-	$script ??= '';
2211
-	if (!$rel) {
2212
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2213
-	} else {
2214
-		if (!is_string($rel)) {
2215
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2216
-		}
2217
-	}
2218
-
2219
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2220
-	if ($script and ($script <> 'accueil' or $rel)) {
2221
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2222
-	} elseif ($args) {
2223
-		$args = "?$args";
2224
-	}
2225
-	if ($ancre) {
2226
-		$args .= "#$ancre";
2227
-	}
2228
-
2229
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2209
+    $script ??= '';
2210
+    if (!$rel) {
2211
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2212
+    } else {
2213
+        if (!is_string($rel)) {
2214
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2215
+        }
2216
+    }
2217
+
2218
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
2219
+    if ($script and ($script <> 'accueil' or $rel)) {
2220
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2221
+    } elseif ($args) {
2222
+        $args = "?$args";
2223
+    }
2224
+    if ($ancre) {
2225
+        $args .= "#$ancre";
2226
+    }
2227
+
2228
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2230 2229
 }
2231 2230
 
2232 2231
 //
@@ -2248,15 +2247,15 @@  discard block
 block discarded – undo
2248 2247
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2249 2248
  **/
2250 2249
 function get_spip_script($default = '') {
2251
-	if (!defined('_SPIP_SCRIPT')) {
2252
-		return 'spip.php';
2253
-	}
2254
-	# cas define('_SPIP_SCRIPT', '');
2255
-	if (_SPIP_SCRIPT) {
2256
-		return _SPIP_SCRIPT;
2257
-	} else {
2258
-		return $default;
2259
-	}
2250
+    if (!defined('_SPIP_SCRIPT')) {
2251
+        return 'spip.php';
2252
+    }
2253
+    # cas define('_SPIP_SCRIPT', '');
2254
+    if (_SPIP_SCRIPT) {
2255
+        return _SPIP_SCRIPT;
2256
+    } else {
2257
+        return $default;
2258
+    }
2260 2259
 }
2261 2260
 
2262 2261
 /**
@@ -2285,45 +2284,45 @@  discard block
 block discarded – undo
2285 2284
  * @return string URL
2286 2285
  **/
2287 2286
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2288
-	// si le script est une action (spip_pass, spip_inscription),
2289
-	// standardiser vers la nouvelle API
2290
-
2291
-	if (is_array($args)) {
2292
-		$args = http_build_query($args);
2293
-	}
2294
-
2295
-	$url = '';
2296
-	if ($f = charger_fonction_url('page')) {
2297
-		$url = $f($script, $args);
2298
-		if ($url and !$rel) {
2299
-			include_spip('inc/filtres_mini');
2300
-			$url = url_absolue($url);
2301
-		}
2302
-	}
2303
-	if (!$url) {
2304
-		if (!$action) {
2305
-			$action = get_spip_script();
2306
-		}
2307
-		if ($script) {
2308
-			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2309
-		}
2310
-		if ($args) {
2311
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2312
-		}
2313
-		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2314
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2315
-	}
2316
-
2317
-	if (!$no_entities) {
2318
-		$url = quote_amp($url);
2319
-	}
2320
-
2321
-	return $url;
2287
+    // si le script est une action (spip_pass, spip_inscription),
2288
+    // standardiser vers la nouvelle API
2289
+
2290
+    if (is_array($args)) {
2291
+        $args = http_build_query($args);
2292
+    }
2293
+
2294
+    $url = '';
2295
+    if ($f = charger_fonction_url('page')) {
2296
+        $url = $f($script, $args);
2297
+        if ($url and !$rel) {
2298
+            include_spip('inc/filtres_mini');
2299
+            $url = url_absolue($url);
2300
+        }
2301
+    }
2302
+    if (!$url) {
2303
+        if (!$action) {
2304
+            $action = get_spip_script();
2305
+        }
2306
+        if ($script) {
2307
+            $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2308
+        }
2309
+        if ($args) {
2310
+            $action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2311
+        }
2312
+        // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2313
+        $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2314
+    }
2315
+
2316
+    if (!$no_entities) {
2317
+        $url = quote_amp($url);
2318
+    }
2319
+
2320
+    return $url;
2322 2321
 }
2323 2322
 
2324 2323
 function generer_url_prive($script, $args = '', $no_entities = false) {
2325 2324
 
2326
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2325
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2327 2326
 }
2328 2327
 
2329 2328
 // Pour les formulaires en methode POST,
@@ -2348,19 +2347,19 @@  discard block
 block discarded – undo
2348 2347
  **/
2349 2348
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2350 2349
 
2351
-	$script1 = explode('&', $script);
2352
-	$script1 = reset($script1);
2350
+    $script1 = explode('&', $script);
2351
+    $script1 = reset($script1);
2353 2352
 
2354
-	return "<form action='"
2355
-	. ($script ? generer_url_ecrire($script) : '')
2356
-	. "' "
2357
-	. ($atts ?: " method='post'")
2358
-	. "><div>\n"
2359
-	. "<input type='hidden' name='exec' value='$script1' />"
2360
-	. $corps
2361
-	. (!$submit ? '' :
2362
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2363
-	. "</div></form>\n";
2353
+    return "<form action='"
2354
+    . ($script ? generer_url_ecrire($script) : '')
2355
+    . "' "
2356
+    . ($atts ?: " method='post'")
2357
+    . "><div>\n"
2358
+    . "<input type='hidden' name='exec' value='$script1' />"
2359
+    . $corps
2360
+    . (!$submit ? '' :
2361
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2362
+    . "</div></form>\n";
2364 2363
 }
2365 2364
 
2366 2365
 /**
@@ -2377,22 +2376,22 @@  discard block
 block discarded – undo
2377 2376
  * @return string
2378 2377
  */
2379 2378
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2380
-	// si l'on est dans l'espace prive, on garde dans l'url
2381
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2382
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2383
-	$h = (_DIR_RACINE and !$public)
2384
-		? generer_url_ecrire(_request('exec'))
2385
-		: generer_url_public();
2379
+    // si l'on est dans l'espace prive, on garde dans l'url
2380
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2381
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2382
+    $h = (_DIR_RACINE and !$public)
2383
+        ? generer_url_ecrire(_request('exec'))
2384
+        : generer_url_public();
2386 2385
 
2387
-	return "\n<form action='" .
2388
-	$h .
2389
-	"'" .
2390
-	$atts .
2391
-	">\n" .
2392
-	'<div>' .
2393
-	"\n<input type='hidden' name='action' value='$script' />" .
2394
-	$corps .
2395
-	'</div></form>';
2386
+    return "\n<form action='" .
2387
+    $h .
2388
+    "'" .
2389
+    $atts .
2390
+    ">\n" .
2391
+    '<div>' .
2392
+    "\n<input type='hidden' name='action' value='$script' />" .
2393
+    $corps .
2394
+    '</div></form>';
2396 2395
 }
2397 2396
 
2398 2397
 /**
@@ -2411,22 +2410,22 @@  discard block
 block discarded – undo
2411 2410
  *     URL
2412 2411
  */
2413 2412
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2414
-	// si l'on est dans l'espace prive, on garde dans l'url
2415
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2416
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2417
-	$url = (_DIR_RACINE and !$public)
2418
-		? generer_url_ecrire(_request('exec'))
2419
-		: generer_url_public('', '', false, false);
2420
-	$url = parametre_url($url, 'action', $script);
2421
-	if ($args) {
2422
-		$url .= quote_amp('&' . $args);
2423
-	}
2413
+    // si l'on est dans l'espace prive, on garde dans l'url
2414
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2415
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2416
+    $url = (_DIR_RACINE and !$public)
2417
+        ? generer_url_ecrire(_request('exec'))
2418
+        : generer_url_public('', '', false, false);
2419
+    $url = parametre_url($url, 'action', $script);
2420
+    if ($args) {
2421
+        $url .= quote_amp('&' . $args);
2422
+    }
2424 2423
 
2425
-	if ($no_entities) {
2426
-		$url = str_replace('&amp;', '&', $url);
2427
-	}
2424
+    if ($no_entities) {
2425
+        $url = str_replace('&amp;', '&', $url);
2426
+    }
2428 2427
 
2429
-	return $url;
2428
+    return $url;
2430 2429
 }
2431 2430
 
2432 2431
 
@@ -2445,23 +2444,23 @@  discard block
 block discarded – undo
2445 2444
  *     URL
2446 2445
  */
2447 2446
 function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
2448
-	if (is_null($public)) {
2449
-		$public = (_DIR_RACINE ? false : '');
2450
-	}
2451
-	if (substr($script, -4) !== '.api') {
2452
-		$script .= '.api';
2453
-	}
2454
-	$url =
2455
-		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2456
-	. $script . '/'
2457
-	. ($path ? trim($path, '/') : '')
2458
-	. ($args ? '?' . quote_amp($args) : '');
2447
+    if (is_null($public)) {
2448
+        $public = (_DIR_RACINE ? false : '');
2449
+    }
2450
+    if (substr($script, -4) !== '.api') {
2451
+        $script .= '.api';
2452
+    }
2453
+    $url =
2454
+        (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2455
+    . $script . '/'
2456
+    . ($path ? trim($path, '/') : '')
2457
+    . ($args ? '?' . quote_amp($args) : '');
2459 2458
 
2460
-	if ($no_entities) {
2461
-		$url = str_replace('&amp;', '&', $url);
2462
-	}
2459
+    if ($no_entities) {
2460
+        $url = str_replace('&amp;', '&', $url);
2461
+    }
2463 2462
 
2464
-	return $url;
2463
+    return $url;
2465 2464
 }
2466 2465
 
2467 2466
 
@@ -2474,8 +2473,8 @@  discard block
 block discarded – undo
2474 2473
  * @param string $ta Répertoire temporaire accessible
2475 2474
  */
2476 2475
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2477
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2478
-	spip_initialisation_suite();
2476
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2477
+    spip_initialisation_suite();
2479 2478
 }
2480 2479
 
2481 2480
 /**
@@ -2495,310 +2494,310 @@  discard block
 block discarded – undo
2495 2494
  * @param string $ta Répertoire temporaire accessible
2496 2495
  */
2497 2496
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2498
-	static $too_late = 0;
2499
-	if ($too_late++) {
2500
-		return;
2501
-	}
2502
-
2503
-	// Declaration des repertoires
2504
-
2505
-	// le nom du repertoire plugins/ activables/desactivables
2506
-	if (!defined('_DIR_PLUGINS')) {
2507
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2508
-	}
2509
-
2510
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2511
-	if (!defined('_DIR_PLUGINS_DIST')) {
2512
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2513
-	}
2514
-
2515
-	// le nom du repertoire des librairies
2516
-	if (!defined('_DIR_LIB')) {
2517
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2518
-	}
2519
-
2520
-	if (!defined('_DIR_IMG')) {
2521
-		define('_DIR_IMG', $pa);
2522
-	}
2523
-	if (!defined('_DIR_LOGOS')) {
2524
-		define('_DIR_LOGOS', $pa);
2525
-	}
2526
-	if (!defined('_DIR_IMG_ICONES')) {
2527
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2528
-	}
2529
-
2530
-	if (!defined('_DIR_DUMP')) {
2531
-		define('_DIR_DUMP', $ti . 'dump/');
2532
-	}
2533
-	if (!defined('_DIR_SESSIONS')) {
2534
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2535
-	}
2536
-	if (!defined('_DIR_TRANSFERT')) {
2537
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2538
-	}
2539
-	if (!defined('_DIR_CACHE')) {
2540
-		define('_DIR_CACHE', $ti . 'cache/');
2541
-	}
2542
-	if (!defined('_DIR_CACHE_XML')) {
2543
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2544
-	}
2545
-	if (!defined('_DIR_SKELS')) {
2546
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2547
-	}
2548
-	if (!defined('_DIR_AIDE')) {
2549
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2550
-	}
2551
-	if (!defined('_DIR_TMP')) {
2552
-		define('_DIR_TMP', $ti);
2553
-	}
2554
-
2555
-	if (!defined('_DIR_VAR')) {
2556
-		define('_DIR_VAR', $ta);
2557
-	}
2558
-
2559
-	if (!defined('_DIR_ETC')) {
2560
-		define('_DIR_ETC', $pi);
2561
-	}
2562
-	if (!defined('_DIR_CONNECT')) {
2563
-		define('_DIR_CONNECT', $pi);
2564
-	}
2565
-	if (!defined('_DIR_CHMOD')) {
2566
-		define('_DIR_CHMOD', $pi);
2567
-	}
2568
-
2569
-	if (!isset($GLOBALS['test_dirs'])) {
2570
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2571
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2572
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2573
-	}
2574
-
2575
-	// Declaration des fichiers
2576
-
2577
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2578
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2579
-	}
2580
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2581
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2582
-	}
2583
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2584
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2585
-	}
2586
-	if (!defined('_CACHE_PIPELINES')) {
2587
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2588
-	}
2589
-	if (!defined('_CACHE_CHEMIN')) {
2590
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2591
-	}
2592
-
2593
-	# attention .php obligatoire pour ecrire_fichier_securise
2594
-	if (!defined('_FILE_META')) {
2595
-		define('_FILE_META', $ti . 'meta_cache.php');
2596
-	}
2597
-	if (!defined('_DIR_LOG')) {
2598
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2599
-	}
2600
-	if (!defined('_FILE_LOG')) {
2601
-		define('_FILE_LOG', 'spip');
2602
-	}
2603
-	if (!defined('_FILE_LOG_SUFFIX')) {
2604
-		define('_FILE_LOG_SUFFIX', '.log');
2605
-	}
2606
-
2607
-	// Le fichier de connexion a la base de donnees
2608
-	// tient compte des anciennes versions (inc_connect...)
2609
-	if (!defined('_FILE_CONNECT_INS')) {
2610
-		define('_FILE_CONNECT_INS', 'connect');
2611
-	}
2612
-	if (!defined('_FILE_CONNECT')) {
2613
-		define(
2614
-			'_FILE_CONNECT',
2615
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2616
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2617
-			: false))
2618
-		);
2619
-	}
2620
-
2621
-	// Le fichier de reglages des droits
2622
-	if (!defined('_FILE_CHMOD_INS')) {
2623
-		define('_FILE_CHMOD_INS', 'chmod');
2624
-	}
2625
-	if (!defined('_FILE_CHMOD')) {
2626
-		define(
2627
-			'_FILE_CHMOD',
2628
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2629
-			: false)
2630
-		);
2631
-	}
2632
-
2633
-	if (!defined('_FILE_LDAP')) {
2634
-		define('_FILE_LDAP', 'ldap.php');
2635
-	}
2636
-
2637
-	if (!defined('_FILE_TMP_SUFFIX')) {
2638
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2639
-	}
2640
-	if (!defined('_FILE_CONNECT_TMP')) {
2641
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2642
-	}
2643
-	if (!defined('_FILE_CHMOD_TMP')) {
2644
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2645
-	}
2646
-
2647
-	// Definition des droits d'acces en ecriture
2648
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2649
-		include_once _FILE_CHMOD;
2650
-	}
2651
-
2652
-	// Se mefier des fichiers mal remplis!
2653
-	if (!defined('_SPIP_CHMOD')) {
2654
-		define('_SPIP_CHMOD', 0777);
2655
-	}
2656
-
2657
-	if (!defined('_DEFAULT_CHARSET')) {
2658
-		/** Le charset par défaut lors de l'installation */
2659
-		define('_DEFAULT_CHARSET', 'utf-8');
2660
-	}
2661
-	if (!defined('_ROOT_PLUGINS')) {
2662
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2663
-	}
2664
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2665
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2666
-	}
2667
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2668
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2669
-	}
2670
-
2671
-	// La taille des Log
2672
-	if (!defined('_MAX_LOG')) {
2673
-		define('_MAX_LOG', 100);
2674
-	}
2675
-
2676
-	// Sommes-nous dans l'empire du Mal ?
2677
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2678
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2679
-		if (!defined('_OS_SERVEUR')) {
2680
-			define('_OS_SERVEUR', 'windows');
2681
-		}
2682
-		if (!defined('_SPIP_LOCK_MODE')) {
2683
-			define('_SPIP_LOCK_MODE', 1);
2684
-		} // utiliser le flock php
2685
-	} else {
2686
-		if (!defined('_OS_SERVEUR')) {
2687
-			define('_OS_SERVEUR', '');
2688
-		}
2689
-		if (!defined('_SPIP_LOCK_MODE')) {
2690
-			define('_SPIP_LOCK_MODE', 1);
2691
-		} // utiliser le flock php
2692
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2693
-	}
2694
-
2695
-	// Langue par defaut
2696
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2697
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2698
-	}
2699
-
2700
-	//
2701
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2702
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2703
-	// pour le rendre surchargeable, on va provoquer un reecriture
2704
-	// systematique du noyau ou une baisse de perfs => a etudier)
2705
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2706
-
2707
-	// charger tout de suite le path et son cache
2708
-	load_path_cache();
2709
-
2710
-	// *********** traiter les variables ************
2711
-
2712
-	//
2713
-	// Securite
2714
-	//
2715
-
2716
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2717
-	if (isset($_REQUEST['GLOBALS'])) {
2718
-		die();
2719
-	}
2720
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2721
-	spip_desinfecte($_GET);
2722
-	spip_desinfecte($_POST);
2723
-	spip_desinfecte($_COOKIE);
2724
-	spip_desinfecte($_REQUEST);
2725
-
2726
-	// appliquer le cookie_prefix
2727
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2728
-		include_spip('inc/cookie');
2729
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2730
-	}
2731
-
2732
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2733
-	if (isset($_SERVER['REQUEST_URI'])) {
2734
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2735
-	} else {
2736
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2737
-		if (
2738
-			!empty($_SERVER['QUERY_STRING'])
2739
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2740
-		) {
2741
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2742
-		}
2743
-	}
2744
-
2745
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2746
-	if (!defined('_RENOUVELLE_ALEA')) {
2747
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2748
-	}
2749
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2750
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2751
-	}
2752
-
2753
-	// charger les meta si possible et renouveller l'alea au besoin
2754
-	// charge aussi effacer_meta et ecrire_meta
2755
-	$inc_meta = charger_fonction('meta', 'inc');
2756
-	$inc_meta();
2757
-
2758
-	// nombre de repertoires depuis la racine
2759
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2760
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2761
-	// le calcul est faux)
2762
-	if (!_DIR_RESTREINT) {
2763
-		$GLOBALS['profondeur_url'] = 1;
2764
-	} else {
2765
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2766
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2767
-		if (
2768
-			!$uri_ref
2769
-			// si on est appele avec un autre ti, on est sans doute en mutu
2770
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2771
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2772
-			// s'en remettre a l'adresse du site. alea jacta est.
2773
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2774
-		) {
2775
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2776
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2777
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2778
-			} else {
2779
-				$uri_ref = '';
2780
-			}
2781
-		}
2782
-		if (!$uri or !$uri_ref) {
2783
-			$GLOBALS['profondeur_url'] = 0;
2784
-		} else {
2785
-			$GLOBALS['profondeur_url'] = max(
2786
-				0,
2787
-				substr_count($uri[0], '/')
2788
-				- substr_count($uri_ref, '/')
2789
-			);
2790
-		}
2791
-	}
2792
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2793
-	if (_FILE_CONNECT) {
2794
-		if (
2795
-			verifier_visiteur() == '0minirezo'
2796
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2797
-			and !isset($_COOKIE['spip_admin'])
2798
-		) {
2799
-			clear_path_cache();
2800
-		}
2801
-	}
2497
+    static $too_late = 0;
2498
+    if ($too_late++) {
2499
+        return;
2500
+    }
2501
+
2502
+    // Declaration des repertoires
2503
+
2504
+    // le nom du repertoire plugins/ activables/desactivables
2505
+    if (!defined('_DIR_PLUGINS')) {
2506
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2507
+    }
2508
+
2509
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2510
+    if (!defined('_DIR_PLUGINS_DIST')) {
2511
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2512
+    }
2513
+
2514
+    // le nom du repertoire des librairies
2515
+    if (!defined('_DIR_LIB')) {
2516
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2517
+    }
2518
+
2519
+    if (!defined('_DIR_IMG')) {
2520
+        define('_DIR_IMG', $pa);
2521
+    }
2522
+    if (!defined('_DIR_LOGOS')) {
2523
+        define('_DIR_LOGOS', $pa);
2524
+    }
2525
+    if (!defined('_DIR_IMG_ICONES')) {
2526
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2527
+    }
2528
+
2529
+    if (!defined('_DIR_DUMP')) {
2530
+        define('_DIR_DUMP', $ti . 'dump/');
2531
+    }
2532
+    if (!defined('_DIR_SESSIONS')) {
2533
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2534
+    }
2535
+    if (!defined('_DIR_TRANSFERT')) {
2536
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2537
+    }
2538
+    if (!defined('_DIR_CACHE')) {
2539
+        define('_DIR_CACHE', $ti . 'cache/');
2540
+    }
2541
+    if (!defined('_DIR_CACHE_XML')) {
2542
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2543
+    }
2544
+    if (!defined('_DIR_SKELS')) {
2545
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2546
+    }
2547
+    if (!defined('_DIR_AIDE')) {
2548
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2549
+    }
2550
+    if (!defined('_DIR_TMP')) {
2551
+        define('_DIR_TMP', $ti);
2552
+    }
2553
+
2554
+    if (!defined('_DIR_VAR')) {
2555
+        define('_DIR_VAR', $ta);
2556
+    }
2557
+
2558
+    if (!defined('_DIR_ETC')) {
2559
+        define('_DIR_ETC', $pi);
2560
+    }
2561
+    if (!defined('_DIR_CONNECT')) {
2562
+        define('_DIR_CONNECT', $pi);
2563
+    }
2564
+    if (!defined('_DIR_CHMOD')) {
2565
+        define('_DIR_CHMOD', $pi);
2566
+    }
2567
+
2568
+    if (!isset($GLOBALS['test_dirs'])) {
2569
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2570
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2571
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2572
+    }
2573
+
2574
+    // Declaration des fichiers
2575
+
2576
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2577
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2578
+    }
2579
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2580
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2581
+    }
2582
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2583
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2584
+    }
2585
+    if (!defined('_CACHE_PIPELINES')) {
2586
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2587
+    }
2588
+    if (!defined('_CACHE_CHEMIN')) {
2589
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2590
+    }
2591
+
2592
+    # attention .php obligatoire pour ecrire_fichier_securise
2593
+    if (!defined('_FILE_META')) {
2594
+        define('_FILE_META', $ti . 'meta_cache.php');
2595
+    }
2596
+    if (!defined('_DIR_LOG')) {
2597
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2598
+    }
2599
+    if (!defined('_FILE_LOG')) {
2600
+        define('_FILE_LOG', 'spip');
2601
+    }
2602
+    if (!defined('_FILE_LOG_SUFFIX')) {
2603
+        define('_FILE_LOG_SUFFIX', '.log');
2604
+    }
2605
+
2606
+    // Le fichier de connexion a la base de donnees
2607
+    // tient compte des anciennes versions (inc_connect...)
2608
+    if (!defined('_FILE_CONNECT_INS')) {
2609
+        define('_FILE_CONNECT_INS', 'connect');
2610
+    }
2611
+    if (!defined('_FILE_CONNECT')) {
2612
+        define(
2613
+            '_FILE_CONNECT',
2614
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2615
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2616
+            : false))
2617
+        );
2618
+    }
2619
+
2620
+    // Le fichier de reglages des droits
2621
+    if (!defined('_FILE_CHMOD_INS')) {
2622
+        define('_FILE_CHMOD_INS', 'chmod');
2623
+    }
2624
+    if (!defined('_FILE_CHMOD')) {
2625
+        define(
2626
+            '_FILE_CHMOD',
2627
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2628
+            : false)
2629
+        );
2630
+    }
2631
+
2632
+    if (!defined('_FILE_LDAP')) {
2633
+        define('_FILE_LDAP', 'ldap.php');
2634
+    }
2635
+
2636
+    if (!defined('_FILE_TMP_SUFFIX')) {
2637
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2638
+    }
2639
+    if (!defined('_FILE_CONNECT_TMP')) {
2640
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2641
+    }
2642
+    if (!defined('_FILE_CHMOD_TMP')) {
2643
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2644
+    }
2645
+
2646
+    // Definition des droits d'acces en ecriture
2647
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2648
+        include_once _FILE_CHMOD;
2649
+    }
2650
+
2651
+    // Se mefier des fichiers mal remplis!
2652
+    if (!defined('_SPIP_CHMOD')) {
2653
+        define('_SPIP_CHMOD', 0777);
2654
+    }
2655
+
2656
+    if (!defined('_DEFAULT_CHARSET')) {
2657
+        /** Le charset par défaut lors de l'installation */
2658
+        define('_DEFAULT_CHARSET', 'utf-8');
2659
+    }
2660
+    if (!defined('_ROOT_PLUGINS')) {
2661
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2662
+    }
2663
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2664
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2665
+    }
2666
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2667
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2668
+    }
2669
+
2670
+    // La taille des Log
2671
+    if (!defined('_MAX_LOG')) {
2672
+        define('_MAX_LOG', 100);
2673
+    }
2674
+
2675
+    // Sommes-nous dans l'empire du Mal ?
2676
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2677
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2678
+        if (!defined('_OS_SERVEUR')) {
2679
+            define('_OS_SERVEUR', 'windows');
2680
+        }
2681
+        if (!defined('_SPIP_LOCK_MODE')) {
2682
+            define('_SPIP_LOCK_MODE', 1);
2683
+        } // utiliser le flock php
2684
+    } else {
2685
+        if (!defined('_OS_SERVEUR')) {
2686
+            define('_OS_SERVEUR', '');
2687
+        }
2688
+        if (!defined('_SPIP_LOCK_MODE')) {
2689
+            define('_SPIP_LOCK_MODE', 1);
2690
+        } // utiliser le flock php
2691
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2692
+    }
2693
+
2694
+    // Langue par defaut
2695
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2696
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2697
+    }
2698
+
2699
+    //
2700
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2701
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2702
+    // pour le rendre surchargeable, on va provoquer un reecriture
2703
+    // systematique du noyau ou une baisse de perfs => a etudier)
2704
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2705
+
2706
+    // charger tout de suite le path et son cache
2707
+    load_path_cache();
2708
+
2709
+    // *********** traiter les variables ************
2710
+
2711
+    //
2712
+    // Securite
2713
+    //
2714
+
2715
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2716
+    if (isset($_REQUEST['GLOBALS'])) {
2717
+        die();
2718
+    }
2719
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2720
+    spip_desinfecte($_GET);
2721
+    spip_desinfecte($_POST);
2722
+    spip_desinfecte($_COOKIE);
2723
+    spip_desinfecte($_REQUEST);
2724
+
2725
+    // appliquer le cookie_prefix
2726
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2727
+        include_spip('inc/cookie');
2728
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2729
+    }
2730
+
2731
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2732
+    if (isset($_SERVER['REQUEST_URI'])) {
2733
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2734
+    } else {
2735
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2736
+        if (
2737
+            !empty($_SERVER['QUERY_STRING'])
2738
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2739
+        ) {
2740
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2741
+        }
2742
+    }
2743
+
2744
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2745
+    if (!defined('_RENOUVELLE_ALEA')) {
2746
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2747
+    }
2748
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2749
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2750
+    }
2751
+
2752
+    // charger les meta si possible et renouveller l'alea au besoin
2753
+    // charge aussi effacer_meta et ecrire_meta
2754
+    $inc_meta = charger_fonction('meta', 'inc');
2755
+    $inc_meta();
2756
+
2757
+    // nombre de repertoires depuis la racine
2758
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2759
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2760
+    // le calcul est faux)
2761
+    if (!_DIR_RESTREINT) {
2762
+        $GLOBALS['profondeur_url'] = 1;
2763
+    } else {
2764
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2765
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
2766
+        if (
2767
+            !$uri_ref
2768
+            // si on est appele avec un autre ti, on est sans doute en mutu
2769
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2770
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2771
+            // s'en remettre a l'adresse du site. alea jacta est.
2772
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2773
+        ) {
2774
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2775
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2776
+                $uri_ref = ($uri_ref['path'] ?? '') . '/';
2777
+            } else {
2778
+                $uri_ref = '';
2779
+            }
2780
+        }
2781
+        if (!$uri or !$uri_ref) {
2782
+            $GLOBALS['profondeur_url'] = 0;
2783
+        } else {
2784
+            $GLOBALS['profondeur_url'] = max(
2785
+                0,
2786
+                substr_count($uri[0], '/')
2787
+                - substr_count($uri_ref, '/')
2788
+            );
2789
+        }
2790
+    }
2791
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2792
+    if (_FILE_CONNECT) {
2793
+        if (
2794
+            verifier_visiteur() == '0minirezo'
2795
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2796
+            and !isset($_COOKIE['spip_admin'])
2797
+        ) {
2798
+            clear_path_cache();
2799
+        }
2800
+    }
2802 2801
 }
2803 2802
 
2804 2803
 /**
@@ -2807,157 +2806,157 @@  discard block
 block discarded – undo
2807 2806
  *
2808 2807
  */
2809 2808
 function spip_initialisation_suite() {
2810
-	static $too_late = 0;
2811
-	if ($too_late++) {
2812
-		return;
2813
-	}
2814
-
2815
-	// taille mini des login
2816
-	if (!defined('_LOGIN_TROP_COURT')) {
2817
-		define('_LOGIN_TROP_COURT', 4);
2818
-	}
2819
-
2820
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2821
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2822
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2823
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2824
-
2825
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2826
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2827
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2828
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2829
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2830
-
2831
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2832
-		define('_PASS_LONGUEUR_MINI', 6);
2833
-	}
2834
-
2835
-	// largeur maximale des images dans l'administration
2836
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2837
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2838
-	}
2839
-
2840
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2841
-	if (!defined('_IMG_QUALITE')) {
2842
-		define('_IMG_QUALITE', 85);
2843
-	} # valeur par defaut
2844
-	if (!defined('_IMG_GD_QUALITE')) {
2845
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2846
-	} # surcharge pour la lib GD
2847
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2848
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2849
-	} # surcharge pour imagick en ligne de commande
2850
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2851
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2852
-		define('_IMG_IMAGICK_QUALITE', 75);
2853
-	} # surcharge pour imagick en PHP
2854
-
2855
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2856
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2857
-	} // poids en octet
2858
-
2859
-	// qq chaines standard
2860
-	if (!defined('_ACCESS_FILE_NAME')) {
2861
-		define('_ACCESS_FILE_NAME', '.htaccess');
2862
-	}
2863
-	if (!defined('_AUTH_USER_FILE')) {
2864
-		define('_AUTH_USER_FILE', '.htpasswd');
2865
-	}
2866
-	if (!defined('_SPIP_DUMP')) {
2867
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2868
-	}
2869
-	if (!defined('_CACHE_RUBRIQUES')) {
2870
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2871
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2872
-	}
2873
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2874
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2875
-		define('_CACHE_RUBRIQUES_MAX', 500);
2876
-	}
2877
-
2878
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2879
-		/**
2880
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2881
-		 * @var int Nombre de caractères */
2882
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2883
-	}
2884
-
2885
-	if (!defined('_EXTENSION_SQUELETTES')) {
2886
-		define('_EXTENSION_SQUELETTES', 'html');
2887
-	}
2888
-
2889
-	if (!defined('_DOCTYPE_ECRIRE')) {
2890
-		/** Définit le doctype de l’espace privé */
2891
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2892
-	}
2893
-	if (!defined('_DOCTYPE_AIDE')) {
2894
-		/** Définit le doctype de l’aide en ligne */
2895
-		define(
2896
-			'_DOCTYPE_AIDE',
2897
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2898
-		);
2899
-	}
2900
-
2901
-	if (!defined('_SPIP_SCRIPT')) {
2902
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2903
-		 * le script de l'espace public, alias index.php */
2904
-		define('_SPIP_SCRIPT', 'spip.php');
2905
-	}
2906
-	if (!defined('_SPIP_PAGE')) {
2907
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2908
-		define('_SPIP_PAGE', 'page');
2909
-	}
2910
-
2911
-	// le script de l'espace prive
2912
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2913
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2914
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2915
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2916
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2917
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2918
-		} else {
2919
-			define('_SPIP_ECRIRE_SCRIPT', '');
2920
-		}
2921
-	}
2922
-
2923
-
2924
-	if (!defined('_SPIP_AJAX')) {
2925
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2926
-			? 1
2927
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2928
-	}
2929
-
2930
-	// La requete est-elle en ajax ?
2931
-	if (!defined('_AJAX')) {
2932
-		define(
2933
-			'_AJAX',
2934
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2935
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2936
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2937
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2938
-			)
2939
-			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
2940
-		);
2941
-	}
2942
-
2943
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2944
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2945
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2946
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2947
-		define(
2948
-			'_IMG_GD_MAX_PIXELS',
2949
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2950
-			? $GLOBALS['meta']['max_taille_vignettes']
2951
-			: 0
2952
-		);
2953
-	}
2954
-
2955
-	// Protocoles a normaliser dans les chaines de langues
2956
-	if (!defined('_PROTOCOLES_STD')) {
2957
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2958
-	}
2959
-
2960
-	init_var_mode();
2809
+    static $too_late = 0;
2810
+    if ($too_late++) {
2811
+        return;
2812
+    }
2813
+
2814
+    // taille mini des login
2815
+    if (!defined('_LOGIN_TROP_COURT')) {
2816
+        define('_LOGIN_TROP_COURT', 4);
2817
+    }
2818
+
2819
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2820
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2821
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2822
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2823
+
2824
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2825
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2826
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2827
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2828
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2829
+
2830
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2831
+        define('_PASS_LONGUEUR_MINI', 6);
2832
+    }
2833
+
2834
+    // largeur maximale des images dans l'administration
2835
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2836
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
2837
+    }
2838
+
2839
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2840
+    if (!defined('_IMG_QUALITE')) {
2841
+        define('_IMG_QUALITE', 85);
2842
+    } # valeur par defaut
2843
+    if (!defined('_IMG_GD_QUALITE')) {
2844
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2845
+    } # surcharge pour la lib GD
2846
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2847
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2848
+    } # surcharge pour imagick en ligne de commande
2849
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2850
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2851
+        define('_IMG_IMAGICK_QUALITE', 75);
2852
+    } # surcharge pour imagick en PHP
2853
+
2854
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2855
+        define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2856
+    } // poids en octet
2857
+
2858
+    // qq chaines standard
2859
+    if (!defined('_ACCESS_FILE_NAME')) {
2860
+        define('_ACCESS_FILE_NAME', '.htaccess');
2861
+    }
2862
+    if (!defined('_AUTH_USER_FILE')) {
2863
+        define('_AUTH_USER_FILE', '.htpasswd');
2864
+    }
2865
+    if (!defined('_SPIP_DUMP')) {
2866
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2867
+    }
2868
+    if (!defined('_CACHE_RUBRIQUES')) {
2869
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2870
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2871
+    }
2872
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2873
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2874
+        define('_CACHE_RUBRIQUES_MAX', 500);
2875
+    }
2876
+
2877
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2878
+        /**
2879
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2880
+         * @var int Nombre de caractères */
2881
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2882
+    }
2883
+
2884
+    if (!defined('_EXTENSION_SQUELETTES')) {
2885
+        define('_EXTENSION_SQUELETTES', 'html');
2886
+    }
2887
+
2888
+    if (!defined('_DOCTYPE_ECRIRE')) {
2889
+        /** Définit le doctype de l’espace privé */
2890
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2891
+    }
2892
+    if (!defined('_DOCTYPE_AIDE')) {
2893
+        /** Définit le doctype de l’aide en ligne */
2894
+        define(
2895
+            '_DOCTYPE_AIDE',
2896
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2897
+        );
2898
+    }
2899
+
2900
+    if (!defined('_SPIP_SCRIPT')) {
2901
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2902
+         * le script de l'espace public, alias index.php */
2903
+        define('_SPIP_SCRIPT', 'spip.php');
2904
+    }
2905
+    if (!defined('_SPIP_PAGE')) {
2906
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2907
+        define('_SPIP_PAGE', 'page');
2908
+    }
2909
+
2910
+    // le script de l'espace prive
2911
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2912
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2913
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2914
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2915
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2916
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2917
+        } else {
2918
+            define('_SPIP_ECRIRE_SCRIPT', '');
2919
+        }
2920
+    }
2921
+
2922
+
2923
+    if (!defined('_SPIP_AJAX')) {
2924
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2925
+            ? 1
2926
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2927
+    }
2928
+
2929
+    // La requete est-elle en ajax ?
2930
+    if (!defined('_AJAX')) {
2931
+        define(
2932
+            '_AJAX',
2933
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2934
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2935
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2936
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2937
+            )
2938
+            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
2939
+        );
2940
+    }
2941
+
2942
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2943
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2944
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2945
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2946
+        define(
2947
+            '_IMG_GD_MAX_PIXELS',
2948
+            (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2949
+            ? $GLOBALS['meta']['max_taille_vignettes']
2950
+            : 0
2951
+        );
2952
+    }
2953
+
2954
+    // Protocoles a normaliser dans les chaines de langues
2955
+    if (!defined('_PROTOCOLES_STD')) {
2956
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2957
+    }
2958
+
2959
+    init_var_mode();
2961 2960
 }
2962 2961
 
2963 2962
 /**
@@ -2991,136 +2990,136 @@  discard block
 block discarded – undo
2991 2990
  * `   var_mode` (calcul ou recalcul).
2992 2991
  */
2993 2992
 function init_var_mode() {
2994
-	static $done = false;
2995
-	if (!$done) {
2996
-		if (isset($_GET['var_mode'])) {
2997
-			$var_mode = explode(',', $_GET['var_mode']);
2998
-			// tout le monde peut calcul/recalcul
2999
-			if (!defined('_VAR_MODE')) {
3000
-				if (in_array('recalcul', $var_mode)) {
3001
-					define('_VAR_MODE', 'recalcul');
3002
-				} elseif (in_array('calcul', $var_mode)) {
3003
-					define('_VAR_MODE', 'calcul');
3004
-				}
3005
-			}
3006
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3007
-			if ($var_mode) {
3008
-				include_spip('inc/autoriser');
3009
-				// autoriser preview si preview seulement, et sinon autoriser debug
3010
-				if (
3011
-					autoriser(
3012
-						($_GET['var_mode'] == 'preview')
3013
-						? 'previsualiser'
3014
-						: 'debug'
3015
-					)
3016
-				) {
3017
-					if (in_array('traduction', $var_mode)) {
3018
-						// forcer le calcul pour passer dans traduire
3019
-						if (!defined('_VAR_MODE')) {
3020
-							define('_VAR_MODE', 'calcul');
3021
-						}
3022
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3023
-						if (!defined('_VAR_NOCACHE')) {
3024
-							define('_VAR_NOCACHE', true);
3025
-						}
3026
-						$var_mode = array_diff($var_mode, ['traduction']);
3027
-					}
3028
-					if (in_array('preview', $var_mode)) {
3029
-						// basculer sur les criteres de preview dans les boucles
3030
-						if (!defined('_VAR_PREVIEW')) {
3031
-							define('_VAR_PREVIEW', true);
3032
-						}
3033
-						// forcer le calcul
3034
-						if (!defined('_VAR_MODE')) {
3035
-							define('_VAR_MODE', 'calcul');
3036
-						}
3037
-						// et ne pas enregistrer de cache
3038
-						if (!defined('_VAR_NOCACHE')) {
3039
-							define('_VAR_NOCACHE', true);
3040
-						}
3041
-						$var_mode = array_diff($var_mode, ['preview']);
3042
-					}
3043
-					if (in_array('inclure', $var_mode)) {
3044
-						// forcer le compilo et ignorer les caches existants
3045
-						if (!defined('_VAR_MODE')) {
3046
-							define('_VAR_MODE', 'calcul');
3047
-						}
3048
-						if (!defined('_VAR_INCLURE')) {
3049
-							define('_VAR_INCLURE', true);
3050
-						}
3051
-						// et ne pas enregistrer de cache
3052
-						if (!defined('_VAR_NOCACHE')) {
3053
-							define('_VAR_NOCACHE', true);
3054
-						}
3055
-						$var_mode = array_diff($var_mode, ['inclure']);
3056
-					}
3057
-					if (in_array('urls', $var_mode)) {
3058
-						// forcer le compilo et ignorer les caches existants
3059
-						if (!defined('_VAR_MODE')) {
3060
-							define('_VAR_MODE', 'calcul');
3061
-						}
3062
-						if (!defined('_VAR_URLS')) {
3063
-							define('_VAR_URLS', true);
3064
-						}
3065
-						$var_mode = array_diff($var_mode, ['urls']);
3066
-					}
3067
-					if (in_array('images', $var_mode)) {
3068
-						// forcer le compilo et ignorer les caches existants
3069
-						if (!defined('_VAR_MODE')) {
3070
-							define('_VAR_MODE', 'calcul');
3071
-						}
3072
-						// indiquer qu'on doit recalculer les images
3073
-						if (!defined('_VAR_IMAGES')) {
3074
-							define('_VAR_IMAGES', true);
3075
-						}
3076
-						$var_mode = array_diff($var_mode, ['images']);
3077
-					}
3078
-					if (in_array('debug', $var_mode)) {
3079
-						if (!defined('_VAR_MODE')) {
3080
-							define('_VAR_MODE', 'debug');
3081
-						}
3082
-						// et ne pas enregistrer de cache
3083
-						if (!defined('_VAR_NOCACHE')) {
3084
-							define('_VAR_NOCACHE', true);
3085
-						}
3086
-						$var_mode = array_diff($var_mode, ['debug']);
3087
-					}
3088
-					if (count($var_mode) and !defined('_VAR_MODE')) {
3089
-						define('_VAR_MODE', reset($var_mode));
3090
-					}
3091
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
3092
-						spip_log($GLOBALS['visiteur_session']['nom']
3093
-							. ' ' . _VAR_MODE);
3094
-					}
3095
-				} // pas autorise ?
3096
-				else {
3097
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3098
-					if (
3099
-						!$GLOBALS['visiteur_session']
3100
-						and !empty($_SERVER['HTTP_HOST'])
3101
-						and !empty($_SERVER['REQUEST_METHOD'])
3102
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3103
-					) {
3104
-						$self = self('&', true);
3105
-						if (strpos($self, 'page=login') === false) {
3106
-							include_spip('inc/headers');
3107
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3108
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3109
-						}
3110
-					}
3111
-					// sinon tant pis
3112
-				}
3113
-			}
3114
-		}
3115
-		if (!defined('_VAR_MODE')) {
3116
-			/**
3117
-			 * Indique le mode de calcul ou d'affichage de la page.
3118
-			 * @see init_var_mode()
3119
-			 */
3120
-			define('_VAR_MODE', false);
3121
-		}
3122
-		$done = true;
3123
-	}
2993
+    static $done = false;
2994
+    if (!$done) {
2995
+        if (isset($_GET['var_mode'])) {
2996
+            $var_mode = explode(',', $_GET['var_mode']);
2997
+            // tout le monde peut calcul/recalcul
2998
+            if (!defined('_VAR_MODE')) {
2999
+                if (in_array('recalcul', $var_mode)) {
3000
+                    define('_VAR_MODE', 'recalcul');
3001
+                } elseif (in_array('calcul', $var_mode)) {
3002
+                    define('_VAR_MODE', 'calcul');
3003
+                }
3004
+            }
3005
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3006
+            if ($var_mode) {
3007
+                include_spip('inc/autoriser');
3008
+                // autoriser preview si preview seulement, et sinon autoriser debug
3009
+                if (
3010
+                    autoriser(
3011
+                        ($_GET['var_mode'] == 'preview')
3012
+                        ? 'previsualiser'
3013
+                        : 'debug'
3014
+                    )
3015
+                ) {
3016
+                    if (in_array('traduction', $var_mode)) {
3017
+                        // forcer le calcul pour passer dans traduire
3018
+                        if (!defined('_VAR_MODE')) {
3019
+                            define('_VAR_MODE', 'calcul');
3020
+                        }
3021
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3022
+                        if (!defined('_VAR_NOCACHE')) {
3023
+                            define('_VAR_NOCACHE', true);
3024
+                        }
3025
+                        $var_mode = array_diff($var_mode, ['traduction']);
3026
+                    }
3027
+                    if (in_array('preview', $var_mode)) {
3028
+                        // basculer sur les criteres de preview dans les boucles
3029
+                        if (!defined('_VAR_PREVIEW')) {
3030
+                            define('_VAR_PREVIEW', true);
3031
+                        }
3032
+                        // forcer le calcul
3033
+                        if (!defined('_VAR_MODE')) {
3034
+                            define('_VAR_MODE', 'calcul');
3035
+                        }
3036
+                        // et ne pas enregistrer de cache
3037
+                        if (!defined('_VAR_NOCACHE')) {
3038
+                            define('_VAR_NOCACHE', true);
3039
+                        }
3040
+                        $var_mode = array_diff($var_mode, ['preview']);
3041
+                    }
3042
+                    if (in_array('inclure', $var_mode)) {
3043
+                        // forcer le compilo et ignorer les caches existants
3044
+                        if (!defined('_VAR_MODE')) {
3045
+                            define('_VAR_MODE', 'calcul');
3046
+                        }
3047
+                        if (!defined('_VAR_INCLURE')) {
3048
+                            define('_VAR_INCLURE', true);
3049
+                        }
3050
+                        // et ne pas enregistrer de cache
3051
+                        if (!defined('_VAR_NOCACHE')) {
3052
+                            define('_VAR_NOCACHE', true);
3053
+                        }
3054
+                        $var_mode = array_diff($var_mode, ['inclure']);
3055
+                    }
3056
+                    if (in_array('urls', $var_mode)) {
3057
+                        // forcer le compilo et ignorer les caches existants
3058
+                        if (!defined('_VAR_MODE')) {
3059
+                            define('_VAR_MODE', 'calcul');
3060
+                        }
3061
+                        if (!defined('_VAR_URLS')) {
3062
+                            define('_VAR_URLS', true);
3063
+                        }
3064
+                        $var_mode = array_diff($var_mode, ['urls']);
3065
+                    }
3066
+                    if (in_array('images', $var_mode)) {
3067
+                        // forcer le compilo et ignorer les caches existants
3068
+                        if (!defined('_VAR_MODE')) {
3069
+                            define('_VAR_MODE', 'calcul');
3070
+                        }
3071
+                        // indiquer qu'on doit recalculer les images
3072
+                        if (!defined('_VAR_IMAGES')) {
3073
+                            define('_VAR_IMAGES', true);
3074
+                        }
3075
+                        $var_mode = array_diff($var_mode, ['images']);
3076
+                    }
3077
+                    if (in_array('debug', $var_mode)) {
3078
+                        if (!defined('_VAR_MODE')) {
3079
+                            define('_VAR_MODE', 'debug');
3080
+                        }
3081
+                        // et ne pas enregistrer de cache
3082
+                        if (!defined('_VAR_NOCACHE')) {
3083
+                            define('_VAR_NOCACHE', true);
3084
+                        }
3085
+                        $var_mode = array_diff($var_mode, ['debug']);
3086
+                    }
3087
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
3088
+                        define('_VAR_MODE', reset($var_mode));
3089
+                    }
3090
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
3091
+                        spip_log($GLOBALS['visiteur_session']['nom']
3092
+                            . ' ' . _VAR_MODE);
3093
+                    }
3094
+                } // pas autorise ?
3095
+                else {
3096
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3097
+                    if (
3098
+                        !$GLOBALS['visiteur_session']
3099
+                        and !empty($_SERVER['HTTP_HOST'])
3100
+                        and !empty($_SERVER['REQUEST_METHOD'])
3101
+                        and $_SERVER['REQUEST_METHOD'] === 'GET'
3102
+                    ) {
3103
+                        $self = self('&', true);
3104
+                        if (strpos($self, 'page=login') === false) {
3105
+                            include_spip('inc/headers');
3106
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3107
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3108
+                        }
3109
+                    }
3110
+                    // sinon tant pis
3111
+                }
3112
+            }
3113
+        }
3114
+        if (!defined('_VAR_MODE')) {
3115
+            /**
3116
+             * Indique le mode de calcul ou d'affichage de la page.
3117
+             * @see init_var_mode()
3118
+             */
3119
+            define('_VAR_MODE', false);
3120
+        }
3121
+        $done = true;
3122
+    }
3124 3123
 }
3125 3124
 
3126 3125
 /**
@@ -3132,16 +3131,16 @@  discard block
 block discarded – undo
3132 3131
  * @param bool $deep = true : appliquer récursivement
3133 3132
 **/
3134 3133
 function spip_desinfecte(&$t, $deep = true) {
3135
-	foreach ($t as $key => $val) {
3136
-		if (is_string($t[$key])) {
3137
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3138
-		} // traiter aussi les "texte_plus" de article_edit
3139
-		else {
3140
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3141
-				spip_desinfecte($t[$key], $deep);
3142
-			}
3143
-		}
3144
-	}
3134
+    foreach ($t as $key => $val) {
3135
+        if (is_string($t[$key])) {
3136
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3137
+        } // traiter aussi les "texte_plus" de article_edit
3138
+        else {
3139
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3140
+                spip_desinfecte($t[$key], $deep);
3141
+            }
3142
+        }
3143
+    }
3145 3144
 }
3146 3145
 
3147 3146
 /**
@@ -3154,64 +3153,64 @@  discard block
 block discarded – undo
3154 3153
  * @return string|0|false
3155 3154
 **/
3156 3155
 function verifier_visiteur() {
3157
-	@spip_initialisation_core(
3158
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3159
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3160
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3161
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3162
-	);
3163
-
3164
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3165
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3166
-	// Attention on separe bien session_nom et nom, pour eviter
3167
-	// les melanges entre donnees SQL et variables plus aleatoires
3168
-	$variables_session = ['session_nom', 'session_email'];
3169
-	foreach ($variables_session as $var) {
3170
-		if (_request($var) !== null) {
3171
-			$init = true;
3172
-			break;
3173
-		}
3174
-	}
3175
-	if (isset($init)) {
3176
-		#@spip_initialisation_suite();
3177
-		$session = charger_fonction('session', 'inc');
3178
-		$session();
3179
-		include_spip('inc/texte');
3180
-		foreach ($variables_session as $var) {
3181
-			if (($a = _request($var)) !== null) {
3182
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3183
-			}
3184
-		}
3185
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3186
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3187
-		}
3188
-		$session($GLOBALS['visiteur_session']);
3189
-
3190
-		return 0;
3191
-	}
3192
-
3193
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3194
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3195
-		$session = charger_fonction('session', 'inc');
3196
-		if ($session()) {
3197
-			return $GLOBALS['visiteur_session']['statut'];
3198
-		}
3199
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3200
-			include_spip('inc/auth');
3201
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3202
-		}
3203
-		if ($h) {
3204
-			$GLOBALS['visiteur_session'] = $h;
3205
-
3206
-			return $GLOBALS['visiteur_session']['statut'];
3207
-		}
3208
-	}
3209
-
3210
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3211
-	include_spip('inc/lang');
3212
-	utiliser_langue_visiteur();
3213
-
3214
-	return false;
3156
+    @spip_initialisation_core(
3157
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3158
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3159
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3160
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3161
+    );
3162
+
3163
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3164
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3165
+    // Attention on separe bien session_nom et nom, pour eviter
3166
+    // les melanges entre donnees SQL et variables plus aleatoires
3167
+    $variables_session = ['session_nom', 'session_email'];
3168
+    foreach ($variables_session as $var) {
3169
+        if (_request($var) !== null) {
3170
+            $init = true;
3171
+            break;
3172
+        }
3173
+    }
3174
+    if (isset($init)) {
3175
+        #@spip_initialisation_suite();
3176
+        $session = charger_fonction('session', 'inc');
3177
+        $session();
3178
+        include_spip('inc/texte');
3179
+        foreach ($variables_session as $var) {
3180
+            if (($a = _request($var)) !== null) {
3181
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3182
+            }
3183
+        }
3184
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3185
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3186
+        }
3187
+        $session($GLOBALS['visiteur_session']);
3188
+
3189
+        return 0;
3190
+    }
3191
+
3192
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3193
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3194
+        $session = charger_fonction('session', 'inc');
3195
+        if ($session()) {
3196
+            return $GLOBALS['visiteur_session']['statut'];
3197
+        }
3198
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3199
+            include_spip('inc/auth');
3200
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3201
+        }
3202
+        if ($h) {
3203
+            $GLOBALS['visiteur_session'] = $h;
3204
+
3205
+            return $GLOBALS['visiteur_session']['statut'];
3206
+        }
3207
+    }
3208
+
3209
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3210
+    include_spip('inc/lang');
3211
+    utiliser_langue_visiteur();
3212
+
3213
+    return false;
3215 3214
 }
3216 3215
 
3217 3216
 
@@ -3234,21 +3233,21 @@  discard block
 block discarded – undo
3234 3233
  *     - string Langue utilisée.
3235 3234
  **/
3236 3235
 function lang_select($lang = null) {
3237
-	static $pile_langues = [];
3238
-	if (!function_exists('changer_langue')) {
3239
-		include_spip('inc/lang');
3240
-	}
3241
-	if ($lang === null) {
3242
-		$lang = array_pop($pile_langues);
3243
-	} else {
3244
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3245
-	}
3246
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3247
-		return $lang;
3248
-	}
3249
-	changer_langue($lang);
3236
+    static $pile_langues = [];
3237
+    if (!function_exists('changer_langue')) {
3238
+        include_spip('inc/lang');
3239
+    }
3240
+    if ($lang === null) {
3241
+        $lang = array_pop($pile_langues);
3242
+    } else {
3243
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3244
+    }
3245
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3246
+        return $lang;
3247
+    }
3248
+    changer_langue($lang);
3250 3249
 
3251
-	return $lang;
3250
+    return $lang;
3252 3251
 }
3253 3252
 
3254 3253
 /**
@@ -3265,20 +3264,20 @@  discard block
 block discarded – undo
3265 3264
  *     Identifiant de la session
3266 3265
  **/
3267 3266
 function spip_session($force = false) {
3268
-	static $session;
3269
-	if ($force or !isset($session)) {
3270
-		$s = pipeline(
3271
-			'definir_session',
3272
-			$GLOBALS['visiteur_session']
3273
-				? serialize($GLOBALS['visiteur_session'])
3274
-				. '_' . @$_COOKIE['spip_session']
3275
-				: ''
3276
-		);
3277
-		$session = $s ? substr(md5($s), 0, 8) : '';
3278
-	}
3267
+    static $session;
3268
+    if ($force or !isset($session)) {
3269
+        $s = pipeline(
3270
+            'definir_session',
3271
+            $GLOBALS['visiteur_session']
3272
+                ? serialize($GLOBALS['visiteur_session'])
3273
+                . '_' . @$_COOKIE['spip_session']
3274
+                : ''
3275
+        );
3276
+        $session = $s ? substr(md5($s), 0, 8) : '';
3277
+    }
3279 3278
 
3280
-	#spip_log('session: '.$session);
3281
-	return $session;
3279
+    #spip_log('session: '.$session);
3280
+    return $session;
3282 3281
 }
3283 3282
 
3284 3283
 
@@ -3297,9 +3296,9 @@  discard block
 block discarded – undo
3297 3296
  *    Lien sur une icone d'aide
3298 3297
  **/
3299 3298
 function aider($aide = '', $distante = false) {
3300
-	$aider = charger_fonction('aide', 'inc', true);
3299
+    $aider = charger_fonction('aide', 'inc', true);
3301 3300
 
3302
-	return $aider ? $aider($aide, '', [], $distante) : '';
3301
+    return $aider ? $aider($aide, '', [], $distante) : '';
3303 3302
 }
3304 3303
 
3305 3304
 /**
@@ -3309,35 +3308,35 @@  discard block
 block discarded – undo
3309 3308
  */
3310 3309
 function exec_info_dist() {
3311 3310
 
3312
-	include_spip('inc/autoriser');
3313
-	if (autoriser('phpinfos')) {
3314
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3315
-		$cookies_backup = [];
3316
-		$server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
3317
-		$env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
3318
-		$mask = '******************************';
3319
-		foreach ($cookies_masques as $k) {
3320
-			if (!empty($_COOKIE[$k])) {
3321
-				$cookies_backup[$k] = $_COOKIE[$k];
3322
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3323
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3324
-				$_COOKIE[$k] = $mask;
3325
-			}
3326
-		}
3327
-		phpinfo();
3328
-		foreach ($cookies_backup as $k => $v) {
3329
-			$_COOKIE[$k] = $v;
3330
-		}
3331
-		foreach ($server_backup as $k => $v) {
3332
-			$_SERVER[$k] = $v;
3333
-		}
3334
-		foreach ($env_backup as $k => $v) {
3335
-			$_ENV[$k] = $v;
3336
-		}
3337
-	} else {
3338
-		include_spip('inc/filtres');
3339
-		sinon_interdire_acces();
3340
-	}
3311
+    include_spip('inc/autoriser');
3312
+    if (autoriser('phpinfos')) {
3313
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3314
+        $cookies_backup = [];
3315
+        $server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
3316
+        $env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
3317
+        $mask = '******************************';
3318
+        foreach ($cookies_masques as $k) {
3319
+            if (!empty($_COOKIE[$k])) {
3320
+                $cookies_backup[$k] = $_COOKIE[$k];
3321
+                $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3322
+                $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3323
+                $_COOKIE[$k] = $mask;
3324
+            }
3325
+        }
3326
+        phpinfo();
3327
+        foreach ($cookies_backup as $k => $v) {
3328
+            $_COOKIE[$k] = $v;
3329
+        }
3330
+        foreach ($server_backup as $k => $v) {
3331
+            $_SERVER[$k] = $v;
3332
+        }
3333
+        foreach ($env_backup as $k => $v) {
3334
+            $_ENV[$k] = $v;
3335
+        }
3336
+    } else {
3337
+        include_spip('inc/filtres');
3338
+        sinon_interdire_acces();
3339
+    }
3341 3340
 }
3342 3341
 
3343 3342
 /**
@@ -3357,13 +3356,13 @@  discard block
 block discarded – undo
3357 3356
  *     - string si $message à false.
3358 3357
  **/
3359 3358
 function erreur_squelette($message = '', $lieu = '') {
3360
-	$debusquer = charger_fonction('debusquer', 'public');
3361
-	if (is_array($lieu)) {
3362
-		include_spip('public/compiler');
3363
-		$lieu = reconstruire_contexte_compil($lieu);
3364
-	}
3359
+    $debusquer = charger_fonction('debusquer', 'public');
3360
+    if (is_array($lieu)) {
3361
+        include_spip('public/compiler');
3362
+        $lieu = reconstruire_contexte_compil($lieu);
3363
+    }
3365 3364
 
3366
-	return $debusquer($message, $lieu);
3365
+    return $debusquer($message, $lieu);
3367 3366
 }
3368 3367
 
3369 3368
 /**
@@ -3400,108 +3399,108 @@  discard block
 block discarded – undo
3400 3399
  *     - ou tableau d'information sur le squelette.
3401 3400
  */
3402 3401
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
3403
-	if (!function_exists('evaluer_fond')) {
3404
-		include_spip('public/assembler');
3405
-	}
3406
-	// assurer la compat avec l'ancienne syntaxe
3407
-	// (trim etait le 3eme argument, par defaut a true)
3408
-	if (!is_array($options)) {
3409
-		$options = ['trim' => $options];
3410
-	}
3411
-	if (!isset($options['trim'])) {
3412
-		$options['trim'] = true;
3413
-	}
3414
-
3415
-	if (isset($contexte['connect'])) {
3416
-		$connect = $contexte['connect'];
3417
-		unset($contexte['connect']);
3418
-	}
3419
-
3420
-	$texte = '';
3421
-	$pages = [];
3422
-	$lang_select = '';
3423
-	if (!isset($options['etoile']) or !$options['etoile']) {
3424
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3425
-		if (!isset($contexte['lang'])) {
3426
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3427
-		}
3428
-
3429
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3430
-			$lang_select = lang_select($contexte['lang']);
3431
-		}
3432
-	}
3433
-
3434
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3435
-		$GLOBALS['_INC_PUBLIC'] = 0;
3436
-	}
3437
-
3438
-	$GLOBALS['_INC_PUBLIC']++;
3439
-
3440
-	// fix #4235
3441
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3442
-
3443
-
3444
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3445
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3446
-
3447
-		$page = evaluer_fond($f, $contexte, $connect);
3448
-		if ($page === '') {
3449
-			$c = $options['compil'] ?? '';
3450
-			$a = ['fichier' => $f];
3451
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3452
-			erreur_squelette($erreur, $c);
3453
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3454
-			$page = ['texte' => '', 'erreur' => $erreur];
3455
-		}
3456
-
3457
-		$page = pipeline('recuperer_fond', [
3458
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3459
-			'data' => $page
3460
-		]);
3461
-		if (isset($options['ajax']) and $options['ajax']) {
3462
-			if (!function_exists('encoder_contexte_ajax')) {
3463
-				include_spip('inc/filtres');
3464
-			}
3465
-			$page['texte'] = encoder_contexte_ajax(
3466
-				array_merge(
3467
-					$contexte,
3468
-					['fond' => $f],
3469
-					($connect ? ['connect' => $connect] : [])
3470
-				),
3471
-				'',
3472
-				$page['texte'],
3473
-				$options['ajax']
3474
-			);
3475
-		}
3476
-
3477
-		if (isset($options['raw']) and $options['raw']) {
3478
-			$pages[] = $page;
3479
-		} else {
3480
-			$texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3481
-		}
3482
-
3483
-		// contamination de la session appelante, pour les inclusions statiques
3484
-		if (isset($page['invalideurs']['session'])) {
3485
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3486
-		}
3487
-	}
3488
-
3489
-	// restaurer le sessionnement du contexte appelant,
3490
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3491
-	if (isset($cache_utilise_session_appelant)) {
3492
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3493
-	}
3494
-
3495
-	$GLOBALS['_INC_PUBLIC']--;
3496
-
3497
-	if ($lang_select) {
3498
-		lang_select();
3499
-	}
3500
-	if (isset($options['raw']) and $options['raw']) {
3501
-		return is_array($fond) ? $pages : reset($pages);
3502
-	} else {
3503
-		return $options['trim'] ? ltrim($texte) : $texte;
3504
-	}
3402
+    if (!function_exists('evaluer_fond')) {
3403
+        include_spip('public/assembler');
3404
+    }
3405
+    // assurer la compat avec l'ancienne syntaxe
3406
+    // (trim etait le 3eme argument, par defaut a true)
3407
+    if (!is_array($options)) {
3408
+        $options = ['trim' => $options];
3409
+    }
3410
+    if (!isset($options['trim'])) {
3411
+        $options['trim'] = true;
3412
+    }
3413
+
3414
+    if (isset($contexte['connect'])) {
3415
+        $connect = $contexte['connect'];
3416
+        unset($contexte['connect']);
3417
+    }
3418
+
3419
+    $texte = '';
3420
+    $pages = [];
3421
+    $lang_select = '';
3422
+    if (!isset($options['etoile']) or !$options['etoile']) {
3423
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3424
+        if (!isset($contexte['lang'])) {
3425
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3426
+        }
3427
+
3428
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3429
+            $lang_select = lang_select($contexte['lang']);
3430
+        }
3431
+    }
3432
+
3433
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3434
+        $GLOBALS['_INC_PUBLIC'] = 0;
3435
+    }
3436
+
3437
+    $GLOBALS['_INC_PUBLIC']++;
3438
+
3439
+    // fix #4235
3440
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3441
+
3442
+
3443
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3444
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3445
+
3446
+        $page = evaluer_fond($f, $contexte, $connect);
3447
+        if ($page === '') {
3448
+            $c = $options['compil'] ?? '';
3449
+            $a = ['fichier' => $f];
3450
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3451
+            erreur_squelette($erreur, $c);
3452
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3453
+            $page = ['texte' => '', 'erreur' => $erreur];
3454
+        }
3455
+
3456
+        $page = pipeline('recuperer_fond', [
3457
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3458
+            'data' => $page
3459
+        ]);
3460
+        if (isset($options['ajax']) and $options['ajax']) {
3461
+            if (!function_exists('encoder_contexte_ajax')) {
3462
+                include_spip('inc/filtres');
3463
+            }
3464
+            $page['texte'] = encoder_contexte_ajax(
3465
+                array_merge(
3466
+                    $contexte,
3467
+                    ['fond' => $f],
3468
+                    ($connect ? ['connect' => $connect] : [])
3469
+                ),
3470
+                '',
3471
+                $page['texte'],
3472
+                $options['ajax']
3473
+            );
3474
+        }
3475
+
3476
+        if (isset($options['raw']) and $options['raw']) {
3477
+            $pages[] = $page;
3478
+        } else {
3479
+            $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3480
+        }
3481
+
3482
+        // contamination de la session appelante, pour les inclusions statiques
3483
+        if (isset($page['invalideurs']['session'])) {
3484
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3485
+        }
3486
+    }
3487
+
3488
+    // restaurer le sessionnement du contexte appelant,
3489
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3490
+    if (isset($cache_utilise_session_appelant)) {
3491
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3492
+    }
3493
+
3494
+    $GLOBALS['_INC_PUBLIC']--;
3495
+
3496
+    if ($lang_select) {
3497
+        lang_select();
3498
+    }
3499
+    if (isset($options['raw']) and $options['raw']) {
3500
+        return is_array($fond) ? $pages : reset($pages);
3501
+    } else {
3502
+        return $options['trim'] ? ltrim($texte) : $texte;
3503
+    }
3505 3504
 }
3506 3505
 
3507 3506
 /**
@@ -3511,7 +3510,7 @@  discard block
 block discarded – undo
3511 3510
  * @return string
3512 3511
  */
3513 3512
 function trouve_modele($nom) {
3514
-	return trouver_fond($nom, 'modeles/');
3513
+    return trouver_fond($nom, 'modeles/');
3515 3514
 }
3516 3515
 
3517 3516
 /**
@@ -3527,21 +3526,21 @@  discard block
 block discarded – undo
3527 3526
  * @return array|string
3528 3527
  */
3529 3528
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3530
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3531
-	if (!$pathinfo) {
3532
-		return $f;
3533
-	}
3534
-	// renvoyer un tableau detaille si $pathinfo==true
3535
-	$p = pathinfo($f);
3536
-	if (!isset($p['extension']) or !$p['extension']) {
3537
-		$p['extension'] = _EXTENSION_SQUELETTES;
3538
-	}
3539
-	if (!isset($p['extension']) or !$p['filename']) {
3540
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3541
-	}
3542
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3529
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3530
+    if (!$pathinfo) {
3531
+        return $f;
3532
+    }
3533
+    // renvoyer un tableau detaille si $pathinfo==true
3534
+    $p = pathinfo($f);
3535
+    if (!isset($p['extension']) or !$p['extension']) {
3536
+        $p['extension'] = _EXTENSION_SQUELETTES;
3537
+    }
3538
+    if (!isset($p['extension']) or !$p['filename']) {
3539
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3540
+    }
3541
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3543 3542
 
3544
-	return $p;
3543
+    return $p;
3545 3544
 }
3546 3545
 
3547 3546
 /**
@@ -3561,21 +3560,21 @@  discard block
 block discarded – undo
3561 3560
  *     Nom de l'exec, sinon chaîne vide.
3562 3561
  **/
3563 3562
 function tester_url_ecrire($nom) {
3564
-	static $exec = [];
3565
-	if (isset($exec[$nom])) {
3566
-		return $exec[$nom];
3567
-	}
3568
-	// tester si c'est une page en squelette
3569
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3570
-		return $exec[$nom] = 'fond';
3571
-	} // echafaudage d'un fond !
3572
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3573
-		return $exec[$nom] = 'fond';
3574
-	}
3575
-	// attention, il ne faut pas inclure l'exec ici
3576
-	// car sinon #URL_ECRIRE provoque des inclusions
3577
-	// et des define intrusifs potentiels
3578
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3563
+    static $exec = [];
3564
+    if (isset($exec[$nom])) {
3565
+        return $exec[$nom];
3566
+    }
3567
+    // tester si c'est une page en squelette
3568
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3569
+        return $exec[$nom] = 'fond';
3570
+    } // echafaudage d'un fond !
3571
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3572
+        return $exec[$nom] = 'fond';
3573
+    }
3574
+    // attention, il ne faut pas inclure l'exec ici
3575
+    // car sinon #URL_ECRIRE provoque des inclusions
3576
+    // et des define intrusifs potentiels
3577
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3579 3578
 }
3580 3579
 
3581 3580
 /**
@@ -3585,8 +3584,8 @@  discard block
 block discarded – undo
3585 3584
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3586 3585
  **/
3587 3586
 function html5_permis() {
3588
-	return (!defined('_VERSION_HTML')
3589
-		or _VERSION_HTML !== 'html4');
3587
+    return (!defined('_VERSION_HTML')
3588
+        or _VERSION_HTML !== 'html4');
3590 3589
 }
3591 3590
 
3592 3591
 /**
@@ -3596,30 +3595,30 @@  discard block
 block discarded – undo
3596 3595
  * @return array
3597 3596
  */
3598 3597
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3599
-	$formats = null;
3600
-	if (!is_null($gd)) {
3601
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3602
-		if (isset($GLOBALS['meta'][$config])) {
3603
-			$formats = $GLOBALS['meta'][$config];
3604
-			$formats = explode(',', $formats);
3605
-			$formats = array_filter($formats);
3606
-			$formats = array_map('trim', $formats);
3607
-		}
3608
-	}
3609
-	if (is_null($formats)) {
3610
-		include_spip('inc/filtres_images_lib_mini');
3611
-		$formats = _image_extensions_acceptees_en_entree();
3612
-	}
3613
-
3614
-	if ($svg_allowed) {
3615
-		if (!in_array('svg', $formats)) {
3616
-			$formats[] = 'svg';
3617
-		}
3618
-	}
3619
-	else {
3620
-		$formats = array_diff($formats, ['svg']);
3621
-	}
3622
-	return $formats;
3598
+    $formats = null;
3599
+    if (!is_null($gd)) {
3600
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3601
+        if (isset($GLOBALS['meta'][$config])) {
3602
+            $formats = $GLOBALS['meta'][$config];
3603
+            $formats = explode(',', $formats);
3604
+            $formats = array_filter($formats);
3605
+            $formats = array_map('trim', $formats);
3606
+        }
3607
+    }
3608
+    if (is_null($formats)) {
3609
+        include_spip('inc/filtres_images_lib_mini');
3610
+        $formats = _image_extensions_acceptees_en_entree();
3611
+    }
3612
+
3613
+    if ($svg_allowed) {
3614
+        if (!in_array('svg', $formats)) {
3615
+            $formats[] = 'svg';
3616
+        }
3617
+    }
3618
+    else {
3619
+        $formats = array_diff($formats, ['svg']);
3620
+    }
3621
+    return $formats;
3623 3622
 }
3624 3623
 
3625 3624
 /**
@@ -3628,20 +3627,20 @@  discard block
 block discarded – undo
3628 3627
  * @return array|bool
3629 3628
  */
3630 3629
 function spip_getimagesize($fichier) {
3631
-	if (!$imagesize = @getimagesize($fichier)) {
3632
-		include_spip('inc/svg');
3633
-		if ($attrs = svg_lire_attributs($fichier)) {
3634
-			[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3635
-			$imagesize = [
3636
-				$width,
3637
-				$height,
3638
-				IMAGETYPE_SVG,
3639
-				"width=\"{$width}\" height=\"{$height}\"",
3640
-				'mime' => 'image/svg+xml'
3641
-			];
3642
-		}
3643
-	}
3644
-	return $imagesize;
3630
+    if (!$imagesize = @getimagesize($fichier)) {
3631
+        include_spip('inc/svg');
3632
+        if ($attrs = svg_lire_attributs($fichier)) {
3633
+            [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3634
+            $imagesize = [
3635
+                $width,
3636
+                $height,
3637
+                IMAGETYPE_SVG,
3638
+                "width=\"{$width}\" height=\"{$height}\"",
3639
+                'mime' => 'image/svg+xml'
3640
+            ];
3641
+        }
3642
+    }
3643
+    return $imagesize;
3645 3644
 }
3646 3645
 
3647 3646
 /**
@@ -3655,19 +3654,19 @@  discard block
 block discarded – undo
3655 3654
  * @param string $statut
3656 3655
  */
3657 3656
 function avertir_auteurs($nom, $message, $statut = '') {
3658
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3659
-	if (
3660
-		!$alertes
3661
-		or !is_array($alertes = unserialize($alertes))
3662
-	) {
3663
-		$alertes = [];
3664
-	}
3657
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3658
+    if (
3659
+        !$alertes
3660
+        or !is_array($alertes = unserialize($alertes))
3661
+    ) {
3662
+        $alertes = [];
3663
+    }
3665 3664
 
3666
-	if (!isset($alertes[$statut])) {
3667
-		$alertes[$statut] = [];
3668
-	}
3669
-	$alertes[$statut][$nom] = $message;
3670
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3665
+    if (!isset($alertes[$statut])) {
3666
+        $alertes[$statut] = [];
3667
+    }
3668
+    $alertes[$statut][$nom] = $message;
3669
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3671 3670
 }
3672 3671
 
3673 3672
 /**
@@ -3681,10 +3680,10 @@  discard block
 block discarded – undo
3681 3680
  * @return string|string[]
3682 3681
  */
3683 3682
 function spip_sanitize_classname($classes) {
3684
-	if (is_array($classes)) {
3685
-		return array_map('spip_sanitize_classname', $classes);
3686
-	}
3687
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3683
+    if (is_array($classes)) {
3684
+        return array_map('spip_sanitize_classname', $classes);
3685
+    }
3686
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3688 3687
 }
3689 3688
 
3690 3689
 
@@ -3709,32 +3708,32 @@  discard block
 block discarded – undo
3709 3708
  *    Avec operateur : bool.
3710 3709
  **/
3711 3710
 function spip_version_compare($v1, $v2, $op = null) {
3712
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3713
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3714
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3715
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3716
-
3717
-	$v1 = explode('.', $v1);
3718
-	$v2 = explode('.', $v2);
3719
-	// $v1 est toujours une version, donc sans etoile
3720
-	while (count($v1) < count($v2)) {
3721
-		$v1[] = '0';
3722
-	}
3723
-
3724
-	// $v2 peut etre une borne, donc accepte l'etoile
3725
-	$etoile = false;
3726
-	foreach ($v1 as $k => $v) {
3727
-		if (!isset($v2[$k])) {
3728
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3729
-		} else {
3730
-			if ($v2[$k] == '*') {
3731
-				$etoile = true;
3732
-				$v2[$k] = $v;
3733
-			}
3734
-		}
3735
-	}
3736
-	$v1 = implode('.', $v1);
3737
-	$v2 = implode('.', $v2);
3738
-
3739
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3711
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3712
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3713
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3714
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3715
+
3716
+    $v1 = explode('.', $v1);
3717
+    $v2 = explode('.', $v2);
3718
+    // $v1 est toujours une version, donc sans etoile
3719
+    while (count($v1) < count($v2)) {
3720
+        $v1[] = '0';
3721
+    }
3722
+
3723
+    // $v2 peut etre une borne, donc accepte l'etoile
3724
+    $etoile = false;
3725
+    foreach ($v1 as $k => $v) {
3726
+        if (!isset($v2[$k])) {
3727
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3728
+        } else {
3729
+            if ($v2[$k] == '*') {
3730
+                $etoile = true;
3731
+                $v2[$k] = $v;
3732
+            }
3733
+        }
3734
+    }
3735
+    $v1 = implode('.', $v1);
3736
+    $v2 = implode('.', $v2);
3737
+
3738
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3740 3739
 }
Please login to merge, or discard this patch.
Spacing   +124 added lines, -125 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	if (strlen($dossier) and substr($dossier, -1) != '/') {
54 54
 		$dossier .= '/';
55 55
 	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
56
+	$f = str_replace('/', '_', $dossier).$nom;
57 57
 
58 58
 	if (function_exists($f)) {
59 59
 		return $f;
60 60
 	}
61
-	if (function_exists($g = $f . '_dist')) {
61
+	if (function_exists($g = $f.'_dist')) {
62 62
 		return $g;
63 63
 	}
64 64
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81 81
 	if (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+		!$inc = include_spip($dossier.($d = strtolower($nom)))
83 83
 		// si le fichier truc/machin/nom.php n'existe pas,
84 84
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85 85
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
+	spip_log("fonction $nom ($f ou $g) indisponible".
102 102
 		($inc ? '' : " (fichier $d absent de $dossier)"));
103 103
 
104 104
 	include_spip('inc/minipres');
105 105
 	echo minipres(
106 106
 		_T('forum_titre_erreur'),
107 107
 		$inc ?
108
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
108
+			_T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>'])
109 109
 			. '<br />'
110
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
110
+			. _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>'])
111 111
 			:
112
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
-		['all_inline' => true,'status' => 404]
112
+			_T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']),
113
+		['all_inline' => true, 'status' => 404]
114 114
 	);
115 115
 	exit;
116 116
 }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  *     - string : chemin du fichier trouvé
157 157
  **/
158 158
 function include_spip($f, $include = true) {
159
-	return find_in_path($f . '.php', '', $include);
159
+	return find_in_path($f.'.php', '', $include);
160 160
 }
161 161
 
162 162
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *     - string : chemin du fichier trouvé
177 177
  **/
178 178
 function require_spip($f) {
179
-	return find_in_path($f . '.php', '', 'required');
179
+	return find_in_path($f.'.php', '', 'required');
180 180
 }
181 181
 
182 182
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		// donc il faut l'inclure "en globals"
194 194
 		if ($f = find_in_path('mes_fonctions.php')) {
195 195
 			global $dossier_squelettes;
196
-			include_once(_ROOT_CWD . $f);
196
+			include_once(_ROOT_CWD.$f);
197 197
 		}
198 198
 
199 199
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	}
299 299
 
300 300
 	// appliquer notre fonction si elle existe
301
-	$fonc = 'execute_pipeline_' . strtolower($action);
301
+	$fonc = 'execute_pipeline_'.strtolower($action);
302 302
 	if (function_exists($fonc)) {
303 303
 		$val = $fonc($val);
304 304
 	} // plantage ?
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 function spip_log($message = null, $name = null) {
364 364
 	static $pre = [];
365 365
 	static $log;
366
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
366
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
367 367
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
368 368
 		$logname = null;
369 369
 	}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		if (!is_string($message)) {
392 392
 			$message = print_r($message, true);
393 393
 		}
394
-		$log($pre[$niveau] . ' ' . $message, $logname);
394
+		$log($pre[$niveau].' '.$message, $logname);
395 395
 	}
396 396
 }
397 397
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	foreach ($regexp as $r => $e) {
598 598
 		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
599 599
 	}
600
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
600
+	$regexp = ',^('.implode('|', $regexp).'[[]?[]]?)(=.*)?$,';
601 601
 	$ajouts = array_flip(explode('|', $c));
602 602
 	$u = is_array($v) ? $v : rawurlencode((string) $v);
603 603
 	$testv = (is_array($v) ? count($v) : strlen((string) $v));
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 			// Ajout. Pour une variable, remplacer au meme endroit,
625 625
 			// pour un tableau ce sera fait dans la prochaine boucle
626 626
 			elseif (substr($r[1], -2) != '[]') {
627
-				$url[$n] = $r[1] . '=' . $u;
627
+				$url[$n] = $r[1].'='.$u;
628 628
 				unset($ajouts[$r[1]]);
629 629
 			}
630 630
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -645,11 +645,11 @@  discard block
 block discarded – undo
645 645
 	} elseif ($testv) {
646 646
 		foreach ($ajouts as $k => $n) {
647 647
 			if (!is_array($v)) {
648
-				$url[] = $k . '=' . $u;
648
+				$url[] = $k.'='.$u;
649 649
 			} else {
650
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
650
+				$id = (substr($k, -2) == '[]') ? $k : ($k.'[]');
651 651
 				foreach ($v as $w) {
652
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
652
+					$url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w));
653 653
 				}
654 654
 			}
655 655
 		}
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 
661 661
 	// recomposer l'adresse
662 662
 	if ($url) {
663
-		$a .= '?' . join($sep, $url);
663
+		$a .= '?'.join($sep, $url);
664 664
 	}
665 665
 
666
-	return $a . $ancre;
666
+	return $a.$ancre;
667 667
 }
668 668
 
669 669
 /**
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 			translitteration($ancre)
696 696
 		);
697 697
 	}
698
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
698
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
699 699
 }
700 700
 
701 701
 /**
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
  * @return bool
812 812
  */
813 813
 function test_plugin_actif($plugin) {
814
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
814
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
815 815
 }
816 816
 
817 817
 /**
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 					$value = interdire_scripts($value, -1);
944 944
 				}
945 945
 				if (!empty($options['class'])) {
946
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
946
+					$value = "<span class='".$options['class']."'>$value</span>";
947 947
 				}
948 948
 				$text = str_replace("@$name@", $value, $text);
949 949
 				unset($args[$name]);
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 		// Si des variables n'ont pas ete inserees, le signaler
953 953
 		// (chaines de langues pas a jour)
954 954
 		if ($args) {
955
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
955
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
956 956
 		}
957 957
 	}
958 958
 
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 function joli_repertoire($rep) {
977 977
 	$a = substr($rep, 0, 1);
978 978
 	if ($a <> '.' and $a <> '/') {
979
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
979
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
980 980
 	}
981 981
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
982 982
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			$p -= ($x * 1000);
1031 1031
 		}
1032 1032
 
1033
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1033
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1034 1034
 	}
1035 1035
 }
1036 1036
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	if ($taches and count($taches) and !spip_connect()) {
1098 1098
 		return false;
1099 1099
 	}
1100
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1100
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1101 1101
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1102 1102
 		return $genie($taches);
1103 1103
 	}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 
1202 1202
 	if ($queue_next_job_time == -1) {
1203 1203
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1204
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1204
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1205 1205
 		}
1206 1206
 		// utiliser un cache memoire si dispo
1207 1207
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 		$src = '';
1271 1271
 	}
1272 1272
 	if ($script) {
1273
-		$script = ("/*<![CDATA[*/\n" .
1274
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1273
+		$script = ("/*<![CDATA[*/\n".
1274
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1275 1275
 			'/*]]>*/');
1276 1276
 	}
1277 1277
 	if ($noscript) {
@@ -1357,13 +1357,13 @@  discard block
 block discarded – undo
1357 1357
 	if ($path_base == null) {
1358 1358
 		// Chemin standard depuis l'espace public
1359 1359
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1360
-			_DIR_RACINE . ':' .
1361
-			_DIR_RACINE . 'squelettes-dist/:' .
1362
-			_DIR_RACINE . 'prive/:' .
1360
+			_DIR_RACINE.':'.
1361
+			_DIR_RACINE.'squelettes-dist/:'.
1362
+			_DIR_RACINE.'prive/:'.
1363 1363
 			_DIR_RESTREINT;
1364 1364
 		// Ajouter squelettes/
1365
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1366
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1365
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1366
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1367 1367
 		}
1368 1368
 		foreach (explode(':', $path) as $dir) {
1369 1369
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 		// Et le(s) dossier(s) des squelettes nommes
1376 1376
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1377 1377
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1378
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1378
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1379 1379
 			}
1380 1380
 		}
1381 1381
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 	if (is_array($dir_path) or strlen($dir_path)) {
1388 1388
 		$tete = '';
1389
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1389
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1390 1390
 			$tete = array_shift($path_base);
1391 1391
 		}
1392 1392
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	// Et le(s) dossier(s) des squelettes nommes
1408 1408
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1409 1409
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1410
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1410
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1411 1411
 		}
1412 1412
 	}
1413 1413
 
@@ -1478,14 +1478,14 @@  discard block
 block discarded – undo
1478 1478
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1479 1479
 	if (
1480 1480
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1481
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1481
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1482 1482
 		and $f = find_in_theme("$file_svg_generique")
1483 1483
 	) {
1484
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1484
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1485 1485
 			return $themefiles["$subdir$file"] = $fsize;
1486 1486
 		}
1487 1487
 		else {
1488
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1488
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1489 1489
 		}
1490 1490
 	}
1491 1491
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			return $themefiles["$subdir$file"] = $f;
1496 1496
 		}
1497 1497
 	}
1498
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1498
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1499 1499
 
1500 1500
 	return $themefiles["$subdir$file"] = '';
1501 1501
 }
@@ -1603,8 +1603,8 @@  discard block
 block discarded – undo
1603 1603
 			return false;
1604 1604
 		}
1605 1605
 		if ($include and !isset($inc[$dirname][$file])) {
1606
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1606
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1608 1608
 		}
1609 1609
 
1610 1610
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1617,14 +1617,14 @@  discard block
 block discarded – undo
1617 1617
 	}
1618 1618
 
1619 1619
 	foreach (creer_chemin() as $dir) {
1620
-		if (!isset($dirs[$a = $dir . $dirname])) {
1621
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1620
+		if (!isset($dirs[$a = $dir.$dirname])) {
1621
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1622 1622
 		}
1623 1623
 		if ($dirs[$a]) {
1624
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1624
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1625 1625
 				if ($include and !isset($inc[$dirname][$file])) {
1626
-					include_once _ROOT_CWD . $a;
1627
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1626
+					include_once _ROOT_CWD.$a;
1627
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1628 1628
 				}
1629 1629
 				if (!defined('_SAUVER_CHEMIN')) {
1630 1630
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 					define('_SAUVER_CHEMIN', true);
1635 1635
 				}
1636 1636
 
1637
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1637
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1638 1638
 			}
1639 1639
 		}
1640 1640
 	}
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
 		define('_SAUVER_CHEMIN', true);
1661 1661
 	}
1662 1662
 
1663
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1663
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1664 1664
 }
1665 1665
 
1666 1666
 function clear_path_cache() {
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1731 1731
 	// on a pas encore inclus flock.php
1732 1732
 	if (!function_exists('preg_files')) {
1733
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1733
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1734 1734
 	}
1735 1735
 
1736 1736
 	// Parcourir le chemin
1737 1737
 	foreach (creer_chemin() as $d) {
1738
-		$f = $d . $dir;
1738
+		$f = $d.$dir;
1739 1739
 		if (@is_dir($f)) {
1740 1740
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1741 1741
 			foreach ($liste as $chemin) {
@@ -1785,9 +1785,9 @@  discard block
 block discarded – undo
1785 1785
 	if ($type === 'defaut') {
1786 1786
 		$objet = objet_type($quoi);
1787 1787
 		if (
1788
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1788
+			$f = charger_fonction('generer_'.$objet.'_url', 'urls', true)
1789 1789
 			// deprecated
1790
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1790
+			or $f = charger_fonction('generer_url_'.$objet, 'urls', true)
1791 1791
 		) {
1792 1792
 			return $f;
1793 1793
 		}
@@ -1800,7 +1800,7 @@  discard block
 block discarded – undo
1800 1800
 	}
1801 1801
 
1802 1802
 	// inclure le module d'url
1803
-	include_spip('urls/' . $url_type);
1803
+	include_spip('urls/'.$url_type);
1804 1804
 
1805 1805
 	switch ($quoi) {
1806 1806
 		case 'page':
@@ -1954,8 +1954,8 @@  discard block
 block discarded – undo
1954 1954
 	include_spip('base/connect_sql');
1955 1955
 	$id_type = id_table_objet($entite, $public);
1956 1956
 
1957
-	return _DIR_RACINE . get_spip_script('./')
1958
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1957
+	return _DIR_RACINE.get_spip_script('./')
1958
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1959 1959
 	. (!$args ? '' : "&$args")
1960 1960
 	. (!$ancre ? '' : "#$ancre");
1961 1961
 }
@@ -2130,7 +2130,7 @@  discard block
 block discarded – undo
2130 2130
 				!empty($_SERVER['QUERY_STRING'])
2131 2131
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2132 2132
 			) {
2133
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2133
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2134 2134
 			}
2135 2135
 		}
2136 2136
 	}
@@ -2168,9 +2168,9 @@  discard block
 block discarded – undo
2168 2168
 		array_shift($myself);
2169 2169
 		$myself = implode('/', $myself);
2170 2170
 	}
2171
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2171
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2172 2172
 
2173
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2173
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2174 2174
 
2175 2175
 	return $url;
2176 2176
 }
@@ -2209,16 +2209,16 @@  discard block
 block discarded – undo
2209 2209
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2210 2210
 	$script ??= '';
2211 2211
 	if (!$rel) {
2212
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2212
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2213 2213
 	} else {
2214 2214
 		if (!is_string($rel)) {
2215
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2215
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
2216 2216
 		}
2217 2217
 	}
2218 2218
 
2219 2219
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2220 2220
 	if ($script and ($script <> 'accueil' or $rel)) {
2221
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2221
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2222 2222
 	} elseif ($args) {
2223 2223
 		$args = "?$args";
2224 2224
 	}
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
 		$args .= "#$ancre";
2227 2227
 	}
2228 2228
 
2229
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2229
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2230 2230
 }
2231 2231
 
2232 2232
 //
@@ -2308,10 +2308,10 @@  discard block
 block discarded – undo
2308 2308
 			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2309 2309
 		}
2310 2310
 		if ($args) {
2311
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2311
+			$action .= (strpos($action, '?') !== false ? '&' : '?').$args;
2312 2312
 		}
2313 2313
 		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2314
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2314
+		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2315 2315
 	}
2316 2316
 
2317 2317
 	if (!$no_entities) {
@@ -2323,7 +2323,7 @@  discard block
 block discarded – undo
2323 2323
 
2324 2324
 function generer_url_prive($script, $args = '', $no_entities = false) {
2325 2325
 
2326
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2326
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2327 2327
 }
2328 2328
 
2329 2329
 // Pour les formulaires en methode POST,
@@ -2358,8 +2358,7 @@  discard block
 block discarded – undo
2358 2358
 	. "><div>\n"
2359 2359
 	. "<input type='hidden' name='exec' value='$script1' />"
2360 2360
 	. $corps
2361
-	. (!$submit ? '' :
2362
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2361
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2363 2362
 	. "</div></form>\n";
2364 2363
 }
2365 2364
 
@@ -2384,14 +2383,14 @@  discard block
 block discarded – undo
2384 2383
 		? generer_url_ecrire(_request('exec'))
2385 2384
 		: generer_url_public();
2386 2385
 
2387
-	return "\n<form action='" .
2388
-	$h .
2389
-	"'" .
2390
-	$atts .
2391
-	">\n" .
2392
-	'<div>' .
2393
-	"\n<input type='hidden' name='action' value='$script' />" .
2394
-	$corps .
2386
+	return "\n<form action='".
2387
+	$h.
2388
+	"'".
2389
+	$atts.
2390
+	">\n".
2391
+	'<div>'.
2392
+	"\n<input type='hidden' name='action' value='$script' />".
2393
+	$corps.
2395 2394
 	'</div></form>';
2396 2395
 }
2397 2396
 
@@ -2419,7 +2418,7 @@  discard block
 block discarded – undo
2419 2418
 		: generer_url_public('', '', false, false);
2420 2419
 	$url = parametre_url($url, 'action', $script);
2421 2420
 	if ($args) {
2422
-		$url .= quote_amp('&' . $args);
2421
+		$url .= quote_amp('&'.$args);
2423 2422
 	}
2424 2423
 
2425 2424
 	if ($no_entities) {
@@ -2453,9 +2452,9 @@  discard block
 block discarded – undo
2453 2452
 	}
2454 2453
 	$url =
2455 2454
 		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2456
-	. $script . '/'
2455
+	. $script.'/'
2457 2456
 	. ($path ? trim($path, '/') : '')
2458
-	. ($args ? '?' . quote_amp($args) : '');
2457
+	. ($args ? '?'.quote_amp($args) : '');
2459 2458
 
2460 2459
 	if ($no_entities) {
2461 2460
 		$url = str_replace('&amp;', '&', $url);
@@ -2504,17 +2503,17 @@  discard block
 block discarded – undo
2504 2503
 
2505 2504
 	// le nom du repertoire plugins/ activables/desactivables
2506 2505
 	if (!defined('_DIR_PLUGINS')) {
2507
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2506
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2508 2507
 	}
2509 2508
 
2510 2509
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2511 2510
 	if (!defined('_DIR_PLUGINS_DIST')) {
2512
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2511
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2513 2512
 	}
2514 2513
 
2515 2514
 	// le nom du repertoire des librairies
2516 2515
 	if (!defined('_DIR_LIB')) {
2517
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2516
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2518 2517
 	}
2519 2518
 
2520 2519
 	if (!defined('_DIR_IMG')) {
@@ -2524,29 +2523,29 @@  discard block
 block discarded – undo
2524 2523
 		define('_DIR_LOGOS', $pa);
2525 2524
 	}
2526 2525
 	if (!defined('_DIR_IMG_ICONES')) {
2527
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2526
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2528 2527
 	}
2529 2528
 
2530 2529
 	if (!defined('_DIR_DUMP')) {
2531
-		define('_DIR_DUMP', $ti . 'dump/');
2530
+		define('_DIR_DUMP', $ti.'dump/');
2532 2531
 	}
2533 2532
 	if (!defined('_DIR_SESSIONS')) {
2534
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2533
+		define('_DIR_SESSIONS', $ti.'sessions/');
2535 2534
 	}
2536 2535
 	if (!defined('_DIR_TRANSFERT')) {
2537
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2536
+		define('_DIR_TRANSFERT', $ti.'upload/');
2538 2537
 	}
2539 2538
 	if (!defined('_DIR_CACHE')) {
2540
-		define('_DIR_CACHE', $ti . 'cache/');
2539
+		define('_DIR_CACHE', $ti.'cache/');
2541 2540
 	}
2542 2541
 	if (!defined('_DIR_CACHE_XML')) {
2543
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2542
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2544 2543
 	}
2545 2544
 	if (!defined('_DIR_SKELS')) {
2546
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2545
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2547 2546
 	}
2548 2547
 	if (!defined('_DIR_AIDE')) {
2549
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2548
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2550 2549
 	}
2551 2550
 	if (!defined('_DIR_TMP')) {
2552 2551
 		define('_DIR_TMP', $ti);
@@ -2575,27 +2574,27 @@  discard block
 block discarded – undo
2575 2574
 	// Declaration des fichiers
2576 2575
 
2577 2576
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2578
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2577
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2579 2578
 	}
2580 2579
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2581
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2580
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2582 2581
 	}
2583 2582
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2584
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2583
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2585 2584
 	}
2586 2585
 	if (!defined('_CACHE_PIPELINES')) {
2587
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2586
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2588 2587
 	}
2589 2588
 	if (!defined('_CACHE_CHEMIN')) {
2590
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2589
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2591 2590
 	}
2592 2591
 
2593 2592
 	# attention .php obligatoire pour ecrire_fichier_securise
2594 2593
 	if (!defined('_FILE_META')) {
2595
-		define('_FILE_META', $ti . 'meta_cache.php');
2594
+		define('_FILE_META', $ti.'meta_cache.php');
2596 2595
 	}
2597 2596
 	if (!defined('_DIR_LOG')) {
2598
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2597
+		define('_DIR_LOG', _DIR_TMP.'log/');
2599 2598
 	}
2600 2599
 	if (!defined('_FILE_LOG')) {
2601 2600
 		define('_FILE_LOG', 'spip');
@@ -2612,8 +2611,8 @@  discard block
 block discarded – undo
2612 2611
 	if (!defined('_FILE_CONNECT')) {
2613 2612
 		define(
2614 2613
 			'_FILE_CONNECT',
2615
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2616
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2614
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2615
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2617 2616
 			: false))
2618 2617
 		);
2619 2618
 	}
@@ -2625,7 +2624,7 @@  discard block
 block discarded – undo
2625 2624
 	if (!defined('_FILE_CHMOD')) {
2626 2625
 		define(
2627 2626
 			'_FILE_CHMOD',
2628
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2627
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2629 2628
 			: false)
2630 2629
 		);
2631 2630
 	}
@@ -2638,10 +2637,10 @@  discard block
 block discarded – undo
2638 2637
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2639 2638
 	}
2640 2639
 	if (!defined('_FILE_CONNECT_TMP')) {
2641
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2640
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2642 2641
 	}
2643 2642
 	if (!defined('_FILE_CHMOD_TMP')) {
2644
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2643
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2645 2644
 	}
2646 2645
 
2647 2646
 	// Definition des droits d'acces en ecriture
@@ -2659,13 +2658,13 @@  discard block
 block discarded – undo
2659 2658
 		define('_DEFAULT_CHARSET', 'utf-8');
2660 2659
 	}
2661 2660
 	if (!defined('_ROOT_PLUGINS')) {
2662
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2661
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2663 2662
 	}
2664 2663
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2665
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2664
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2666 2665
 	}
2667 2666
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2668
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2667
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2669 2668
 	}
2670 2669
 
2671 2670
 	// La taille des Log
@@ -2702,7 +2701,7 @@  discard block
 block discarded – undo
2702 2701
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2703 2702
 	// pour le rendre surchargeable, on va provoquer un reecriture
2704 2703
 	// systematique du noyau ou une baisse de perfs => a etudier)
2705
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2704
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2706 2705
 
2707 2706
 	// charger tout de suite le path et son cache
2708 2707
 	load_path_cache();
@@ -2738,7 +2737,7 @@  discard block
 block discarded – undo
2738 2737
 			!empty($_SERVER['QUERY_STRING'])
2739 2738
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2740 2739
 		) {
2741
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2740
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2742 2741
 		}
2743 2742
 	}
2744 2743
 
@@ -2774,7 +2773,7 @@  discard block
 block discarded – undo
2774 2773
 		) {
2775 2774
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2776 2775
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2777
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2776
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
2778 2777
 			} else {
2779 2778
 				$uri_ref = '';
2780 2779
 			}
@@ -2868,7 +2867,7 @@  discard block
 block discarded – undo
2868 2867
 	}
2869 2868
 	if (!defined('_CACHE_RUBRIQUES')) {
2870 2869
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2871
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2870
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2872 2871
 	}
2873 2872
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2874 2873
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -3090,7 +3089,7 @@  discard block
 block discarded – undo
3090 3089
 					}
3091 3090
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
3092 3091
 						spip_log($GLOBALS['visiteur_session']['nom']
3093
-							. ' ' . _VAR_MODE);
3092
+							. ' '._VAR_MODE);
3094 3093
 					}
3095 3094
 				} // pas autorise ?
3096 3095
 				else {
@@ -3105,7 +3104,7 @@  discard block
 block discarded – undo
3105 3104
 						if (strpos($self, 'page=login') === false) {
3106 3105
 							include_spip('inc/headers');
3107 3106
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3108
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3107
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3109 3108
 						}
3110 3109
 					}
3111 3110
 					// sinon tant pis
@@ -3155,10 +3154,10 @@  discard block
 block discarded – undo
3155 3154
 **/
3156 3155
 function verifier_visiteur() {
3157 3156
 	@spip_initialisation_core(
3158
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3159
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3160
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3161
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3157
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3158
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3159
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3160
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3162 3161
 	);
3163 3162
 
3164 3163
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3191,7 +3190,7 @@  discard block
 block discarded – undo
3191 3190
 	}
3192 3191
 
3193 3192
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3194
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3193
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3195 3194
 		$session = charger_fonction('session', 'inc');
3196 3195
 		if ($session()) {
3197 3196
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3271,7 +3270,7 @@  discard block
 block discarded – undo
3271 3270
 			'definir_session',
3272 3271
 			$GLOBALS['visiteur_session']
3273 3272
 				? serialize($GLOBALS['visiteur_session'])
3274
-				. '_' . @$_COOKIE['spip_session']
3273
+				. '_'.@$_COOKIE['spip_session']
3275 3274
 				: ''
3276 3275
 		);
3277 3276
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3319,8 +3318,8 @@  discard block
 block discarded – undo
3319 3318
 		foreach ($cookies_masques as $k) {
3320 3319
 			if (!empty($_COOKIE[$k])) {
3321 3320
 				$cookies_backup[$k] = $_COOKIE[$k];
3322
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3323
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3321
+				$_SERVER['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3322
+				$_ENV['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3324 3323
 				$_COOKIE[$k] = $mask;
3325 3324
 			}
3326 3325
 		}
@@ -3438,11 +3437,11 @@  discard block
 block discarded – undo
3438 3437
 	$GLOBALS['_INC_PUBLIC']++;
3439 3438
 
3440 3439
 	// fix #4235
3441
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3440
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
3442 3441
 
3443 3442
 
3444 3443
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3445
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3444
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3446 3445
 
3447 3446
 		$page = evaluer_fond($f, $contexte, $connect);
3448 3447
 		if ($page === '') {
@@ -3527,7 +3526,7 @@  discard block
 block discarded – undo
3527 3526
  * @return array|string
3528 3527
  */
3529 3528
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3530
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3529
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3531 3530
 	if (!$pathinfo) {
3532 3531
 		return $f;
3533 3532
 	}
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147 147
 	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148 148
 			. $data[$root]
149
-			. '</option>' . "\n";
149
+			. '</option>'."\n";
150 150
 	} else {
151 151
 		$r = '';
152 152
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	// et voila le travail
177
-	return $r . $sous;
177
+	return $r.$sous;
178 178
 }
179 179
 
180 180
 /**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 	while ($r = sql_fetch($q)) {
222 222
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
223 223
 			// titre largeur maxi a 50
224
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
224
+			$titre = couper(supprimer_tags(typo($r['titre'])).' ', 50);
225 225
 			if (
226 226
 				$GLOBALS['meta']['multi_rubriques'] == 'oui'
227 227
 				and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
228 228
 			) {
229
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
229
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
230 230
 			}
231 231
 			$data[$r['id_rubrique']] = $titre;
232 232
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
254 254
 
255 255
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
256
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
256
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
257 257
 	} else {
258
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
258
+		$r = '<select'.$att." size='1'>\n$opt</select>\n";
259 259
 	}
260 260
 
261 261
 	# message pour neuneus (a supprimer ?)
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
298 298
 
299 299
 	if ($id_rubrique) {
300
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
300
+		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique));
301 301
 	} else {
302 302
 		if ($type == 'auteur') {
303 303
 			$titre = '&nbsp;';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	}
308 308
 
309 309
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
310
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
310
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
311 311
 
312 312
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
313 313
 		. (!$idem ? '' : "&exclus=$idem")
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		. " jQuery(this).toggleClass('toggled'); "
357 357
 		. "return charger_node_url_si_vide('"
358 358
 		. $url
359
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
359
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>"
360 360
 		. $img_icone
361 361
 		. "</a><img src='"
362 362
 		. chemin_image('loader.svg')
Please login to merge, or discard this patch.
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
25
-	/**
26
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques.
27
-	 * Au delà, on bascule sur un sélecteur ajax.
28
-	 * mettre 100000 pour desactiver ajax
29
-	 */
30
-	define('_SPIP_SELECT_RUBRIQUES', 20);
25
+    /**
26
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques.
27
+     * Au delà, on bascule sur un sélecteur ajax.
28
+     * mettre 100000 pour desactiver ajax
29
+     */
30
+    define('_SPIP_SELECT_RUBRIQUES', 20);
31 31
 }
32 32
 
33 33
 /**
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
  *     Code HTML du sélecteur
56 56
  **/
57 57
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
58
-	if (sql_countsel('spip_rubriques') < 1) {
59
-		return '';
60
-	}
61
-
62
-	// Mode sans Ajax :
63
-	// - soit parce que le cookie ajax n'est pas la
64
-	// - soit parce qu'il y a peu de rubriques
65
-	if (
66
-		_SPIP_AJAX < 1
67
-		or $type == 'breve'
68
-		or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
69
-	) {
70
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
71
-	} else {
72
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
73
-	}
58
+    if (sql_countsel('spip_rubriques') < 1) {
59
+        return '';
60
+    }
61
+
62
+    // Mode sans Ajax :
63
+    // - soit parce que le cookie ajax n'est pas la
64
+    // - soit parce qu'il y a peu de rubriques
65
+    if (
66
+        _SPIP_AJAX < 1
67
+        or $type == 'breve'
68
+        or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
69
+    ) {
70
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
71
+    } else {
72
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
73
+    }
74 74
 }
75 75
 
76 76
 // compatibilite pour extensions qui utilisaient l'ancien nom
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
  **/
88 88
 function style_menu_rubriques($i) {
89 89
 
90
-	$espace = '';
91
-	$style = '';
92
-	for ($count = 1; $count <= $i; $count++) {
93
-		$espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
94
-	}
95
-	if ($i == 1) {
96
-		$espace = '';
97
-	}
98
-	$class = "niveau_$i";
99
-
100
-	return [$class, $style, $espace];
90
+    $espace = '';
91
+    $style = '';
92
+    for ($count = 1; $count <= $i; $count++) {
93
+        $espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
94
+    }
95
+    if ($i == 1) {
96
+        $espace = '';
97
+    }
98
+    $class = "niveau_$i";
99
+
100
+    return [$class, $style, $espace];
101 101
 }
102 102
 
103 103
 /**
@@ -121,60 +121,60 @@  discard block
 block discarded – undo
121 121
  *     Code HTML du sélecteur
122 122
  **/
123 123
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
124
-	static $decalage_secteur;
125
-
126
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
-	if (
128
-		$exclus > 0
129
-		and $root == $exclus
130
-	) {
131
-		return '';
132
-	}
133
-
134
-	// en fonction du niveau faire un affichage plus ou moins kikoo
135
-
136
-	// selected ?
137
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
138
-
139
-	// le style en fonction de la profondeur
140
-	[$class, $style, $espace] = style_menu_rubriques($niv);
141
-
142
-	$class .= ' selec_rub';
143
-
144
-	// creer l'<option> pour la rubrique $root
145
-
146
-	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147
-	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
-			. $data[$root]
149
-			. '</option>' . "\n";
150
-	} else {
151
-		$r = '';
152
-	}
153
-
154
-	// et le sous-menu pour ses enfants
155
-	$sous = '';
156
-	if (isset($enfants[$root])) {
157
-		foreach ($enfants[$root] as $sousrub) {
158
-			$sous .= sous_menu_rubriques(
159
-				$id_rubrique,
160
-				$sousrub,
161
-				$niv + 1,
162
-				$data,
163
-				$enfants,
164
-				$exclus,
165
-				$restreint,
166
-				$type
167
-			);
168
-		}
169
-	}
170
-
171
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
172
-	if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
173
-		return $sous;
174
-	}
175
-
176
-	// et voila le travail
177
-	return $r . $sous;
124
+    static $decalage_secteur;
125
+
126
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
+    if (
128
+        $exclus > 0
129
+        and $root == $exclus
130
+    ) {
131
+        return '';
132
+    }
133
+
134
+    // en fonction du niveau faire un affichage plus ou moins kikoo
135
+
136
+    // selected ?
137
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
138
+
139
+    // le style en fonction de la profondeur
140
+    [$class, $style, $espace] = style_menu_rubriques($niv);
141
+
142
+    $class .= ' selec_rub';
143
+
144
+    // creer l'<option> pour la rubrique $root
145
+
146
+    if (isset($data[$root])) { # pas de racine sauf pour les rubriques
147
+    $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
+            . $data[$root]
149
+            . '</option>' . "\n";
150
+    } else {
151
+        $r = '';
152
+    }
153
+
154
+    // et le sous-menu pour ses enfants
155
+    $sous = '';
156
+    if (isset($enfants[$root])) {
157
+        foreach ($enfants[$root] as $sousrub) {
158
+            $sous .= sous_menu_rubriques(
159
+                $id_rubrique,
160
+                $sousrub,
161
+                $niv + 1,
162
+                $data,
163
+                $enfants,
164
+                $exclus,
165
+                $restreint,
166
+                $type
167
+            );
168
+        }
169
+    }
170
+
171
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
172
+    if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
173
+        return $sous;
174
+    }
175
+
176
+    // et voila le travail
177
+    return $r . $sous;
178 178
 }
179 179
 
180 180
 /**
@@ -195,75 +195,75 @@  discard block
 block discarded – undo
195 195
  *     Code HTML du sélecteur
196 196
  **/
197 197
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
198
-	$enfants = [];
199
-	$data = [];
200
-	if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
201
-		$data[0] = _T('info_racine_site');
202
-	}
203
-	# premier choix = neant
204
-	# si auteur (rubriques restreintes)
205
-	# ou si creation avec id_rubrique=0
206
-	elseif ($type == 'auteur' or !$id_rubrique) {
207
-		$data[0] = '&nbsp;';
208
-	}
209
-
210
-	//
211
-	// creer une structure contenant toute l'arborescence
212
-	//
213
-
214
-	include_spip('base/abstract_sql');
215
-	$q = sql_select(
216
-		'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
217
-		'spip_rubriques',
218
-		($type == 'breve' ? ' id_parent=0 ' : ''),
219
-		'',
220
-		'0+titre,titre'
221
-	);
222
-	while ($r = sql_fetch($q)) {
223
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
224
-			// titre largeur maxi a 50
225
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
226
-			if (
227
-				$GLOBALS['meta']['multi_rubriques'] == 'oui'
228
-				and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
229
-			) {
230
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
231
-			}
232
-			$data[$r['id_rubrique']] = $titre;
233
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
234
-			if ($id_rubrique == $r['id_rubrique']) {
235
-				$id_parent = $r['id_parent'];
236
-			}
237
-		}
238
-	}
239
-
240
-	// si une seule rubrique comme choix possible,
241
-	// inutile de mettre le selecteur sur un choix vide par defaut
242
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
243
-	if (
244
-		count($data) == 2
245
-		and isset($data[0])
246
-		and !in_array($type, ['auteur', 'rubrique'])
247
-		and !$id_rubrique
248
-	) {
249
-		unset($data[0]);
250
-	}
251
-
252
-
253
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
254
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
255
-
256
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
257
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
258
-	} else {
259
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
260
-	}
261
-
262
-	# message pour neuneus (a supprimer ?)
198
+    $enfants = [];
199
+    $data = [];
200
+    if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
201
+        $data[0] = _T('info_racine_site');
202
+    }
203
+    # premier choix = neant
204
+    # si auteur (rubriques restreintes)
205
+    # ou si creation avec id_rubrique=0
206
+    elseif ($type == 'auteur' or !$id_rubrique) {
207
+        $data[0] = '&nbsp;';
208
+    }
209
+
210
+    //
211
+    // creer une structure contenant toute l'arborescence
212
+    //
213
+
214
+    include_spip('base/abstract_sql');
215
+    $q = sql_select(
216
+        'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
217
+        'spip_rubriques',
218
+        ($type == 'breve' ? ' id_parent=0 ' : ''),
219
+        '',
220
+        '0+titre,titre'
221
+    );
222
+    while ($r = sql_fetch($q)) {
223
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
224
+            // titre largeur maxi a 50
225
+            $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
226
+            if (
227
+                $GLOBALS['meta']['multi_rubriques'] == 'oui'
228
+                and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0)
229
+            ) {
230
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
231
+            }
232
+            $data[$r['id_rubrique']] = $titre;
233
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
234
+            if ($id_rubrique == $r['id_rubrique']) {
235
+                $id_parent = $r['id_parent'];
236
+            }
237
+        }
238
+    }
239
+
240
+    // si une seule rubrique comme choix possible,
241
+    // inutile de mettre le selecteur sur un choix vide par defaut
242
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
243
+    if (
244
+        count($data) == 2
245
+        and isset($data[0])
246
+        and !in_array($type, ['auteur', 'rubrique'])
247
+        and !$id_rubrique
248
+    ) {
249
+        unset($data[0]);
250
+    }
251
+
252
+
253
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
254
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
255
+
256
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
257
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
258
+    } else {
259
+        $r = '<select' . $att . " size='1'>\n$opt</select>\n";
260
+    }
261
+
262
+    # message pour neuneus (a supprimer ?)
263 263
 #	if ($type != 'auteur' AND $type != 'breve')
264 264
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
265 265
 
266
-	return $r;
266
+    return $r;
267 267
 }
268 268
 
269 269
 /**
@@ -297,26 +297,26 @@  discard block
 block discarded – undo
297 297
  */
298 298
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
299 299
 
300
-	if ($id_rubrique) {
301
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
302
-	} else {
303
-		if ($type == 'auteur') {
304
-			$titre = '&nbsp;';
305
-		} else {
306
-			$titre = _T('info_racine_site');
307
-		}
308
-	}
300
+    if ($id_rubrique) {
301
+        $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
302
+    } else {
303
+        if ($type == 'auteur') {
304
+            $titre = '&nbsp;';
305
+        } else {
306
+            $titre = _T('info_racine_site');
307
+        }
308
+    }
309 309
 
310
-	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
311
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
310
+    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
311
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
312 312
 
313
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
314
-		. (!$idem ? '' : "&exclus=$idem")
315
-		. ($restreint ? '' : '&racine=oui')
316
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
313
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
314
+        . (!$idem ? '' : "&exclus=$idem")
315
+        . ($restreint ? '' : '&racine=oui')
316
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
317 317
 
318 318
 
319
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
319
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
320 320
 }
321 321
 
322 322
 /**
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  *     Code HTML du sélecteur de rubrique AJAX
347 347
  **/
348 348
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
349
-	$icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
350
-	// si icone de recherche on embed le svg
351
-	$balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
352
-	$img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
353
-
354
-	return
355
-		"<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
356
-		. $js
357
-		. " jQuery(this).toggleClass('toggled'); "
358
-		. "return charger_node_url_si_vide('"
359
-		. $url
360
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
361
-		. $img_icone
362
-		. "</a><img src='"
363
-		. chemin_image('loader.svg')
364
-		. "' class='loader' id='img_"
365
-		. $idom
366
-		. "'\nstyle='visibility: hidden;' alt='*' />"
367
-		. "<input id='titreparent' name='titreparent' class='text'"
368
-		. $init
369
-		. ' />'
370
-		. "<input type='hidden' id='$name' name='$name' value='"
371
-		. $id
372
-		. "' /><div class='nettoyeur'></div></div><div id='"
373
-		. $idom
374
-		. "'\nstyle='display: none;'></div>";
349
+    $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
350
+    // si icone de recherche on embed le svg
351
+    $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
352
+    $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
353
+
354
+    return
355
+        "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
356
+        . $js
357
+        . " jQuery(this).toggleClass('toggled'); "
358
+        . "return charger_node_url_si_vide('"
359
+        . $url
360
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
361
+        . $img_icone
362
+        . "</a><img src='"
363
+        . chemin_image('loader.svg')
364
+        . "' class='loader' id='img_"
365
+        . $idom
366
+        . "'\nstyle='visibility: hidden;' alt='*' />"
367
+        . "<input id='titreparent' name='titreparent' class='text'"
368
+        . $init
369
+        . ' />'
370
+        . "<input type='hidden' id='$name' name='$name' value='"
371
+        . $id
372
+        . "' /><div class='nettoyeur'></div></div><div id='"
373
+        . $idom
374
+        . "'\nstyle='display: none;'></div>";
375 375
 }
Please login to merge, or discard this patch.