Completed
Push — master ( fb0017...92433c )
by cam
01:14
created
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.
Spacing   +125 added lines, -126 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
 /**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			translitteration($ancre)
694 694
 		);
695 695
 	}
696
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
696
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
697 697
 }
698 698
 
699 699
 /**
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
  * @return bool
810 810
  */
811 811
 function test_plugin_actif($plugin) {
812
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
812
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
813 813
 }
814 814
 
815 815
 /**
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 					$value = interdire_scripts($value, -1);
942 942
 				}
943 943
 				if (!empty($options['class'])) {
944
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
944
+					$value = "<span class='".$options['class']."'>$value</span>";
945 945
 				}
946 946
 				$text = str_replace("@$name@", $value, $text);
947 947
 				unset($args[$name]);
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 		// Si des variables n'ont pas ete inserees, le signaler
951 951
 		// (chaines de langues pas a jour)
952 952
 		if ($args) {
953
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
953
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
954 954
 		}
955 955
 	}
956 956
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 function joli_repertoire($rep) {
975 975
 	$a = substr($rep, 0, 1);
976 976
 	if ($a <> '.' and $a <> '/') {
977
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
977
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
978 978
 	}
979 979
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
980 980
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$p -= ($x * 1000);
1029 1029
 		}
1030 1030
 
1031
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1031
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1032 1032
 	}
1033 1033
 }
1034 1034
 
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 	if ($taches and count($taches) and !spip_connect()) {
1096 1096
 		return false;
1097 1097
 	}
1098
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1098
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1099 1099
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1100 1100
 		return $genie($taches);
1101 1101
 	}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 
1200 1200
 	if ($queue_next_job_time == -1) {
1201 1201
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1202
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1202
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1203 1203
 		}
1204 1204
 		// utiliser un cache memoire si dispo
1205 1205
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1268,8 +1268,8 @@  discard block
 block discarded – undo
1268 1268
 		$src = '';
1269 1269
 	}
1270 1270
 	if ($script) {
1271
-		$script = ("/*<![CDATA[*/\n" .
1272
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1271
+		$script = ("/*<![CDATA[*/\n".
1272
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1273 1273
 			'/*]]>*/');
1274 1274
 	}
1275 1275
 	if ($noscript) {
@@ -1355,13 +1355,13 @@  discard block
 block discarded – undo
1355 1355
 	if ($path_base == null) {
1356 1356
 		// Chemin standard depuis l'espace public
1357 1357
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1358
-			_DIR_RACINE . ':' .
1359
-			_DIR_RACINE . 'squelettes-dist/:' .
1360
-			_DIR_RACINE . 'prive/:' .
1358
+			_DIR_RACINE.':'.
1359
+			_DIR_RACINE.'squelettes-dist/:'.
1360
+			_DIR_RACINE.'prive/:'.
1361 1361
 			_DIR_RESTREINT;
1362 1362
 		// Ajouter squelettes/
1363
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1364
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1363
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1364
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1365 1365
 		}
1366 1366
 		foreach (explode(':', $path) as $dir) {
1367 1367
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		// Et le(s) dossier(s) des squelettes nommes
1374 1374
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1375 1375
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1376
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1376
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1377 1377
 			}
1378 1378
 		}
1379 1379
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 
1385 1385
 	if (is_array($dir_path) or strlen($dir_path)) {
1386 1386
 		$tete = '';
1387
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1387
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1388 1388
 			$tete = array_shift($path_base);
1389 1389
 		}
1390 1390
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 	// Et le(s) dossier(s) des squelettes nommes
1406 1406
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1407 1407
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1408
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1408
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1409 1409
 		}
1410 1410
 	}
1411 1411
 
@@ -1476,14 +1476,14 @@  discard block
 block discarded – undo
1476 1476
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1477 1477
 	if (
1478 1478
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1479
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1479
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1480 1480
 		and $f = find_in_theme("$file_svg_generique")
1481 1481
 	) {
1482
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1482
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1483 1483
 			return $themefiles["$subdir$file"] = $fsize;
1484 1484
 		}
1485 1485
 		else {
1486
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1486
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1487 1487
 		}
1488 1488
 	}
1489 1489
 
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 			return $themefiles["$subdir$file"] = $f;
1494 1494
 		}
1495 1495
 	}
1496
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1496
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1497 1497
 
1498 1498
 	return $themefiles["$subdir$file"] = '';
1499 1499
 }
@@ -1601,8 +1601,8 @@  discard block
 block discarded – undo
1601 1601
 			return false;
1602 1602
 		}
1603 1603
 		if ($include and !isset($inc[$dirname][$file])) {
1604
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1605
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1604
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1605
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1606 1606
 		}
1607 1607
 
1608 1608
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1615,14 +1615,14 @@  discard block
 block discarded – undo
1615 1615
 	}
1616 1616
 
1617 1617
 	foreach (creer_chemin() as $dir) {
1618
-		if (!isset($dirs[$a = $dir . $dirname])) {
1619
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1618
+		if (!isset($dirs[$a = $dir.$dirname])) {
1619
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1620 1620
 		}
1621 1621
 		if ($dirs[$a]) {
1622
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1622
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1623 1623
 				if ($include and !isset($inc[$dirname][$file])) {
1624
-					include_once _ROOT_CWD . $a;
1625
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1624
+					include_once _ROOT_CWD.$a;
1625
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1626 1626
 				}
1627 1627
 				if (!defined('_SAUVER_CHEMIN')) {
1628 1628
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 					define('_SAUVER_CHEMIN', true);
1633 1633
 				}
1634 1634
 
1635
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1635
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1636 1636
 			}
1637 1637
 		}
1638 1638
 	}
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 		define('_SAUVER_CHEMIN', true);
1659 1659
 	}
1660 1660
 
1661
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1661
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1662 1662
 }
1663 1663
 
1664 1664
 function clear_path_cache() {
@@ -1728,12 +1728,12 @@  discard block
 block discarded – undo
1728 1728
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1729 1729
 	// on a pas encore inclus flock.php
1730 1730
 	if (!function_exists('preg_files')) {
1731
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1731
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1732 1732
 	}
1733 1733
 
1734 1734
 	// Parcourir le chemin
1735 1735
 	foreach (creer_chemin() as $d) {
1736
-		$f = $d . $dir;
1736
+		$f = $d.$dir;
1737 1737
 		if (@is_dir($f)) {
1738 1738
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1739 1739
 			foreach ($liste as $chemin) {
@@ -1783,9 +1783,9 @@  discard block
 block discarded – undo
1783 1783
 	if ($type === 'defaut') {
1784 1784
 		$objet = objet_type($quoi);
1785 1785
 		if (
1786
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1786
+			$f = charger_fonction('generer_'.$objet.'_url', 'urls', true)
1787 1787
 			// deprecated
1788
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1788
+			or $f = charger_fonction('generer_url_'.$objet, 'urls', true)
1789 1789
 		) {
1790 1790
 			return $f;
1791 1791
 		}
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
 	}
1799 1799
 
1800 1800
 	// inclure le module d'url
1801
-	include_spip('urls/' . $url_type);
1801
+	include_spip('urls/'.$url_type);
1802 1802
 
1803 1803
 	switch ($quoi) {
1804 1804
 		case 'page':
@@ -1951,8 +1951,8 @@  discard block
 block discarded – undo
1951 1951
 	include_spip('base/connect_sql');
1952 1952
 	$id_type = id_table_objet($entite, $public);
1953 1953
 
1954
-	return _DIR_RACINE . get_spip_script('./')
1955
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1954
+	return _DIR_RACINE.get_spip_script('./')
1955
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1956 1956
 	. (!$args ? '' : "&$args")
1957 1957
 	. (!$ancre ? '' : "#$ancre");
1958 1958
 }
@@ -2127,7 +2127,7 @@  discard block
 block discarded – undo
2127 2127
 				!empty($_SERVER['QUERY_STRING'])
2128 2128
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2129 2129
 			) {
2130
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2130
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2131 2131
 			}
2132 2132
 		}
2133 2133
 	}
@@ -2165,9 +2165,9 @@  discard block
 block discarded – undo
2165 2165
 		array_shift($myself);
2166 2166
 		$myself = implode('/', $myself);
2167 2167
 	}
2168
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2168
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2169 2169
 
2170
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2170
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2171 2171
 
2172 2172
 	return $url;
2173 2173
 }
@@ -2206,16 +2206,16 @@  discard block
 block discarded – undo
2206 2206
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2207 2207
 	$script ??= '';
2208 2208
 	if (!$rel) {
2209
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2209
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2210 2210
 	} else {
2211 2211
 		if (!is_string($rel)) {
2212
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2212
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
2213 2213
 		}
2214 2214
 	}
2215 2215
 
2216 2216
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2217 2217
 	if ($script and ($script <> 'accueil' or $rel)) {
2218
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2218
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2219 2219
 	} elseif ($args) {
2220 2220
 		$args = "?$args";
2221 2221
 	}
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
 		$args .= "#$ancre";
2224 2224
 	}
2225 2225
 
2226
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2226
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2227 2227
 }
2228 2228
 
2229 2229
 //
@@ -2305,10 +2305,10 @@  discard block
 block discarded – undo
2305 2305
 			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2306 2306
 		}
2307 2307
 		if ($args) {
2308
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2308
+			$action .= (strpos($action, '?') !== false ? '&' : '?').$args;
2309 2309
 		}
2310 2310
 		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2311
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2311
+		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2312 2312
 	}
2313 2313
 
2314 2314
 	if (!$no_entities) {
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
 
2321 2321
 function generer_url_prive($script, $args = '', $no_entities = false) {
2322 2322
 
2323
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2323
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2324 2324
 }
2325 2325
 
2326 2326
 // Pour les formulaires en methode POST,
@@ -2355,8 +2355,7 @@  discard block
 block discarded – undo
2355 2355
 	. "><div>\n"
2356 2356
 	. "<input type='hidden' name='exec' value='$script1' />"
2357 2357
 	. $corps
2358
-	. (!$submit ? '' :
2359
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2358
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2360 2359
 	. "</div></form>\n";
2361 2360
 }
2362 2361
 
@@ -2381,14 +2380,14 @@  discard block
 block discarded – undo
2381 2380
 		? generer_url_ecrire(_request('exec'))
2382 2381
 		: generer_url_public();
2383 2382
 
2384
-	return "\n<form action='" .
2385
-	$h .
2386
-	"'" .
2387
-	$atts .
2388
-	">\n" .
2389
-	'<div>' .
2390
-	"\n<input type='hidden' name='action' value='$script' />" .
2391
-	$corps .
2383
+	return "\n<form action='".
2384
+	$h.
2385
+	"'".
2386
+	$atts.
2387
+	">\n".
2388
+	'<div>'.
2389
+	"\n<input type='hidden' name='action' value='$script' />".
2390
+	$corps.
2392 2391
 	'</div></form>';
2393 2392
 }
2394 2393
 
@@ -2416,7 +2415,7 @@  discard block
 block discarded – undo
2416 2415
 		: generer_url_public('', '', false, false);
2417 2416
 	$url = parametre_url($url, 'action', $script);
2418 2417
 	if ($args) {
2419
-		$url .= quote_amp('&' . $args);
2418
+		$url .= quote_amp('&'.$args);
2420 2419
 	}
2421 2420
 
2422 2421
 	if ($no_entities) {
@@ -2450,9 +2449,9 @@  discard block
 block discarded – undo
2450 2449
 	}
2451 2450
 	$url =
2452 2451
 		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2453
-	. $script . '/'
2452
+	. $script.'/'
2454 2453
 	. ($path ? trim($path, '/') : '')
2455
-	. ($args ? '?' . quote_amp($args) : '');
2454
+	. ($args ? '?'.quote_amp($args) : '');
2456 2455
 
2457 2456
 	if ($no_entities) {
2458 2457
 		$url = str_replace('&amp;', '&', $url);
@@ -2501,22 +2500,22 @@  discard block
 block discarded – undo
2501 2500
 
2502 2501
 	// le nom du repertoire plugins/ activables/desactivables
2503 2502
 	if (!defined('_DIR_PLUGINS')) {
2504
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2503
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2505 2504
 	}
2506 2505
 
2507 2506
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2508 2507
 	if (!defined('_DIR_PLUGINS_DIST')) {
2509
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2508
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2510 2509
 	}
2511 2510
 
2512 2511
 	// le nom du repertoire des librairies
2513 2512
 	if (!defined('_DIR_LIB')) {
2514
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2513
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2515 2514
 	}
2516 2515
 
2517 2516
 	// répertoire des libs via Composer
2518 2517
 	if (!defined('_DIR_VENDOR')) {
2519
-		define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
2518
+		define('_DIR_VENDOR', _DIR_RACINE.'vendor/');
2520 2519
 	}
2521 2520
 
2522 2521
 	if (!defined('_DIR_IMG')) {
@@ -2526,29 +2525,29 @@  discard block
 block discarded – undo
2526 2525
 		define('_DIR_LOGOS', $pa);
2527 2526
 	}
2528 2527
 	if (!defined('_DIR_IMG_ICONES')) {
2529
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2528
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2530 2529
 	}
2531 2530
 
2532 2531
 	if (!defined('_DIR_DUMP')) {
2533
-		define('_DIR_DUMP', $ti . 'dump/');
2532
+		define('_DIR_DUMP', $ti.'dump/');
2534 2533
 	}
2535 2534
 	if (!defined('_DIR_SESSIONS')) {
2536
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2535
+		define('_DIR_SESSIONS', $ti.'sessions/');
2537 2536
 	}
2538 2537
 	if (!defined('_DIR_TRANSFERT')) {
2539
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2538
+		define('_DIR_TRANSFERT', $ti.'upload/');
2540 2539
 	}
2541 2540
 	if (!defined('_DIR_CACHE')) {
2542
-		define('_DIR_CACHE', $ti . 'cache/');
2541
+		define('_DIR_CACHE', $ti.'cache/');
2543 2542
 	}
2544 2543
 	if (!defined('_DIR_CACHE_XML')) {
2545
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2544
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2546 2545
 	}
2547 2546
 	if (!defined('_DIR_SKELS')) {
2548
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2547
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2549 2548
 	}
2550 2549
 	if (!defined('_DIR_AIDE')) {
2551
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2550
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2552 2551
 	}
2553 2552
 	if (!defined('_DIR_TMP')) {
2554 2553
 		define('_DIR_TMP', $ti);
@@ -2577,27 +2576,27 @@  discard block
 block discarded – undo
2577 2576
 	// Declaration des fichiers
2578 2577
 
2579 2578
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2580
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2579
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2581 2580
 	}
2582 2581
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2583
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2582
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2584 2583
 	}
2585 2584
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2586
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2585
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2587 2586
 	}
2588 2587
 	if (!defined('_CACHE_PIPELINES')) {
2589
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2588
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2590 2589
 	}
2591 2590
 	if (!defined('_CACHE_CHEMIN')) {
2592
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2591
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2593 2592
 	}
2594 2593
 
2595 2594
 	# attention .php obligatoire pour ecrire_fichier_securise
2596 2595
 	if (!defined('_FILE_META')) {
2597
-		define('_FILE_META', $ti . 'meta_cache.php');
2596
+		define('_FILE_META', $ti.'meta_cache.php');
2598 2597
 	}
2599 2598
 	if (!defined('_DIR_LOG')) {
2600
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2599
+		define('_DIR_LOG', _DIR_TMP.'log/');
2601 2600
 	}
2602 2601
 	if (!defined('_FILE_LOG')) {
2603 2602
 		define('_FILE_LOG', 'spip');
@@ -2614,8 +2613,8 @@  discard block
 block discarded – undo
2614 2613
 	if (!defined('_FILE_CONNECT')) {
2615 2614
 		define(
2616 2615
 			'_FILE_CONNECT',
2617
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2618
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2616
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2617
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2619 2618
 			: false))
2620 2619
 		);
2621 2620
 	}
@@ -2627,7 +2626,7 @@  discard block
 block discarded – undo
2627 2626
 	if (!defined('_FILE_CHMOD')) {
2628 2627
 		define(
2629 2628
 			'_FILE_CHMOD',
2630
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2629
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2631 2630
 			: false)
2632 2631
 		);
2633 2632
 	}
@@ -2640,10 +2639,10 @@  discard block
 block discarded – undo
2640 2639
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2641 2640
 	}
2642 2641
 	if (!defined('_FILE_CONNECT_TMP')) {
2643
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2642
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2644 2643
 	}
2645 2644
 	if (!defined('_FILE_CHMOD_TMP')) {
2646
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2645
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2647 2646
 	}
2648 2647
 
2649 2648
 	// Definition des droits d'acces en ecriture
@@ -2661,13 +2660,13 @@  discard block
 block discarded – undo
2661 2660
 		define('_DEFAULT_CHARSET', 'utf-8');
2662 2661
 	}
2663 2662
 	if (!defined('_ROOT_PLUGINS')) {
2664
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2663
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2665 2664
 	}
2666 2665
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2667
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2666
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2668 2667
 	}
2669 2668
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2670
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2669
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2671 2670
 	}
2672 2671
 
2673 2672
 	// La taille des Log
@@ -2704,7 +2703,7 @@  discard block
 block discarded – undo
2704 2703
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2705 2704
 	// pour le rendre surchargeable, on va provoquer un reecriture
2706 2705
 	// systematique du noyau ou une baisse de perfs => a etudier)
2707
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2706
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2708 2707
 
2709 2708
 	// charger tout de suite le path et son cache
2710 2709
 	load_path_cache();
@@ -2740,7 +2739,7 @@  discard block
 block discarded – undo
2740 2739
 			!empty($_SERVER['QUERY_STRING'])
2741 2740
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2742 2741
 		) {
2743
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2742
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2744 2743
 		}
2745 2744
 	}
2746 2745
 
@@ -2776,7 +2775,7 @@  discard block
 block discarded – undo
2776 2775
 		) {
2777 2776
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2778 2777
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2779
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2778
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
2780 2779
 			} else {
2781 2780
 				$uri_ref = '';
2782 2781
 			}
@@ -2870,7 +2869,7 @@  discard block
 block discarded – undo
2870 2869
 	}
2871 2870
 	if (!defined('_CACHE_RUBRIQUES')) {
2872 2871
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2873
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2872
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2874 2873
 	}
2875 2874
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2876 2875
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -3092,7 +3091,7 @@  discard block
 block discarded – undo
3092 3091
 					}
3093 3092
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
3094 3093
 						spip_log($GLOBALS['visiteur_session']['nom']
3095
-							. ' ' . _VAR_MODE);
3094
+							. ' '._VAR_MODE);
3096 3095
 					}
3097 3096
 				} // pas autorise ?
3098 3097
 				else {
@@ -3107,7 +3106,7 @@  discard block
 block discarded – undo
3107 3106
 						if (strpos($self, 'page=login') === false) {
3108 3107
 							include_spip('inc/headers');
3109 3108
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3110
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3109
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3111 3110
 						}
3112 3111
 					}
3113 3112
 					// sinon tant pis
@@ -3157,10 +3156,10 @@  discard block
 block discarded – undo
3157 3156
 **/
3158 3157
 function verifier_visiteur() {
3159 3158
 	@spip_initialisation_core(
3160
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3161
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3162
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3163
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3159
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3160
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3161
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3162
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3164 3163
 	);
3165 3164
 
3166 3165
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3193,7 +3192,7 @@  discard block
 block discarded – undo
3193 3192
 	}
3194 3193
 
3195 3194
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3196
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3195
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3197 3196
 		$session = charger_fonction('session', 'inc');
3198 3197
 		if ($session()) {
3199 3198
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3273,7 +3272,7 @@  discard block
 block discarded – undo
3273 3272
 			'definir_session',
3274 3273
 			$GLOBALS['visiteur_session']
3275 3274
 				? serialize($GLOBALS['visiteur_session'])
3276
-				. '_' . @$_COOKIE['spip_session']
3275
+				. '_'.@$_COOKIE['spip_session']
3277 3276
 				: ''
3278 3277
 		);
3279 3278
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3321,8 +3320,8 @@  discard block
 block discarded – undo
3321 3320
 		foreach ($cookies_masques as $k) {
3322 3321
 			if (!empty($_COOKIE[$k])) {
3323 3322
 				$cookies_backup[$k] = $_COOKIE[$k];
3324
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3325
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3323
+				$_SERVER['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3324
+				$_ENV['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3326 3325
 				$_COOKIE[$k] = $mask;
3327 3326
 			}
3328 3327
 		}
@@ -3440,11 +3439,11 @@  discard block
 block discarded – undo
3440 3439
 	$GLOBALS['_INC_PUBLIC']++;
3441 3440
 
3442 3441
 	// fix #4235
3443
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3442
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
3444 3443
 
3445 3444
 
3446 3445
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3447
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3446
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3448 3447
 
3449 3448
 		$page = evaluer_fond($f, $contexte, $connect);
3450 3449
 		if ($page === '') {
@@ -3529,7 +3528,7 @@  discard block
 block discarded – undo
3529 3528
  * @return array|string
3530 3529
  */
3531 3530
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3532
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3531
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3533 3532
 	if (!$pathinfo) {
3534 3533
 		return $f;
3535 3534
 	}
Please login to merge, or discard this patch.
Indentation   +2269 added lines, -2270 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
 /**
@@ -678,22 +677,22 @@  discard block
 block discarded – undo
678 677
  * @uses translitteration()
679 678
  */
680 679
 function ancre_url(string $url, ?string $ancre = ''): string {
681
-	$ancre ??= '';
682
-	// lever l'#ancre
683
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
684
-		$url = $r[1];
685
-	}
686
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
687
-		if (!function_exists('translitteration')) {
688
-			include_spip('inc/charsets');
689
-		}
690
-		$ancre = preg_replace(
691
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
692
-			['', '-'],
693
-			translitteration($ancre)
694
-		);
695
-	}
696
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
680
+    $ancre ??= '';
681
+    // lever l'#ancre
682
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
683
+        $url = $r[1];
684
+    }
685
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
686
+        if (!function_exists('translitteration')) {
687
+            include_spip('inc/charsets');
688
+        }
689
+        $ancre = preg_replace(
690
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
691
+            ['', '-'],
692
+            translitteration($ancre)
693
+        );
694
+    }
695
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
697 696
 }
698 697
 
699 698
 /**
@@ -703,16 +702,16 @@  discard block
 block discarded – undo
703 702
  * @return string
704 703
  */
705 704
 function nettoyer_uri($reset = null) {
706
-	static $done = false;
707
-	static $propre = '';
708
-	if (!is_null($reset)) {
709
-		return $propre = $reset;
710
-	}
711
-	if ($done) {
712
-		return $propre;
713
-	}
714
-	$done = true;
715
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
705
+    static $done = false;
706
+    static $propre = '';
707
+    if (!is_null($reset)) {
708
+        return $propre = $reset;
709
+    }
710
+    if ($done) {
711
+        return $propre;
712
+    }
713
+    $done = true;
714
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
716 715
 }
717 716
 
718 717
 /**
@@ -724,16 +723,16 @@  discard block
 block discarded – undo
724 723
  * @return string
725 724
  */
726 725
 function nettoyer_uri_var($request_uri) {
727
-	$uri1 = $request_uri;
728
-	do {
729
-		$uri = $uri1;
730
-		$uri1 = preg_replace(
731
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
732
-			'\1',
733
-			$uri
734
-		);
735
-	} while ($uri <> $uri1);
736
-	return preg_replace(',[?&]$,', '', $uri1);
726
+    $uri1 = $request_uri;
727
+    do {
728
+        $uri = $uri1;
729
+        $uri1 = preg_replace(
730
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
731
+            '\1',
732
+            $uri
733
+        );
734
+    } while ($uri <> $uri1);
735
+    return preg_replace(',[?&]$,', '', $uri1);
737 736
 }
738 737
 
739 738
 
@@ -747,48 +746,48 @@  discard block
 block discarded – undo
747 746
  *    URL vers soi-même
748 747
  **/
749 748
 function self($amp = '&amp;', $root = false) {
750
-	$url = nettoyer_uri();
751
-	if (
752
-		!$root
753
-		and (
754
-			// si pas de profondeur on peut tronquer
755
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
756
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
757
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
758
-	) {
759
-		$url = preg_replace(',^[^?]*/,', '', $url);
760
-	}
761
-	// ajouter le cas echeant les variables _POST['id_...']
762
-	foreach ($_POST as $v => $c) {
763
-		if (substr($v, 0, 3) == 'id_') {
764
-			$url = parametre_url($url, $v, $c, '&');
765
-		}
766
-	}
767
-
768
-	// supprimer les variables sans interet
769
-	if (test_espace_prive()) {
770
-		$url = preg_replace(',([?&])('
771
-			. 'lang|show_docs|'
772
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
773
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
774
-		$url = preg_replace(',[&]$,', '\1', $url);
775
-	}
776
-
777
-	// eviter les hacks
778
-	include_spip('inc/filtres_mini');
779
-	$url = spip_htmlspecialchars($url);
780
-
781
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
782
-
783
-	// &amp; ?
784
-	if ($amp != '&amp;') {
785
-		$url = str_replace('&amp;', $amp, $url);
786
-	}
787
-
788
-	// Si ca demarre par ? ou vide, donner './'
789
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
790
-
791
-	return $url;
749
+    $url = nettoyer_uri();
750
+    if (
751
+        !$root
752
+        and (
753
+            // si pas de profondeur on peut tronquer
754
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
755
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
756
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
757
+    ) {
758
+        $url = preg_replace(',^[^?]*/,', '', $url);
759
+    }
760
+    // ajouter le cas echeant les variables _POST['id_...']
761
+    foreach ($_POST as $v => $c) {
762
+        if (substr($v, 0, 3) == 'id_') {
763
+            $url = parametre_url($url, $v, $c, '&');
764
+        }
765
+    }
766
+
767
+    // supprimer les variables sans interet
768
+    if (test_espace_prive()) {
769
+        $url = preg_replace(',([?&])('
770
+            . 'lang|show_docs|'
771
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
772
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
773
+        $url = preg_replace(',[&]$,', '\1', $url);
774
+    }
775
+
776
+    // eviter les hacks
777
+    include_spip('inc/filtres_mini');
778
+    $url = spip_htmlspecialchars($url);
779
+
780
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
781
+
782
+    // &amp; ?
783
+    if ($amp != '&amp;') {
784
+        $url = str_replace('&amp;', $amp, $url);
785
+    }
786
+
787
+    // Si ca demarre par ? ou vide, donner './'
788
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
789
+
790
+    return $url;
792 791
 }
793 792
 
794 793
 
@@ -799,7 +798,7 @@  discard block
 block discarded – undo
799 798
  *     true si c'est le cas, false sinon.
800 799
  */
801 800
 function test_espace_prive() {
802
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
801
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
803 802
 }
804 803
 
805 804
 /**
@@ -809,7 +808,7 @@  discard block
 block discarded – undo
809 808
  * @return bool
810 809
  */
811 810
 function test_plugin_actif($plugin) {
812
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
811
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
813 812
 }
814 813
 
815 814
 /**
@@ -840,52 +839,52 @@  discard block
 block discarded – undo
840 839
  *     texte
841 840
  */
842 841
 function _T($texte, $args = [], $options = []) {
843
-	static $traduire = false;
844
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
845
-	if ($options) {
846
-		// support de l'ancien argument $class
847
-		if (is_string($options)) {
848
-			$options = ['class' => $options];
849
-		}
850
-		$o = array_merge($o, $options);
851
-	}
852
-
853
-	if (!$traduire) {
854
-		$traduire = charger_fonction('traduire', 'inc');
855
-		include_spip('inc/lang');
856
-	}
857
-
858
-	// On peut passer explicitement la langue dans le tableau
859
-	// On utilise le même nom de variable que la globale
860
-	if (isset($args['spip_lang'])) {
861
-		$lang = $args['spip_lang'];
862
-		// On l'enleve pour ne pas le passer au remplacement
863
-		unset($args['spip_lang']);
864
-	} // Sinon on prend la langue du contexte
865
-	else {
866
-		$lang = $GLOBALS['spip_lang'];
867
-	}
868
-	$text = $traduire($texte, $lang);
869
-
870
-	if ($text === null || !strlen($text)) {
871
-		if (!$o['force']) {
872
-			return '';
873
-		}
874
-
875
-		$text = $texte;
876
-
877
-		// pour les chaines non traduites, assurer un service minimum
878
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
879
-			$n = strpos($text, ':');
880
-			if ($n !== false) {
881
-				$text = substr($text, $n + 1);
882
-			}
883
-			$text = str_replace('_', ' ', $text);
884
-		}
885
-		$o['class'] = null;
886
-	}
887
-
888
-	return _L($text, $args, $o);
842
+    static $traduire = false;
843
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
844
+    if ($options) {
845
+        // support de l'ancien argument $class
846
+        if (is_string($options)) {
847
+            $options = ['class' => $options];
848
+        }
849
+        $o = array_merge($o, $options);
850
+    }
851
+
852
+    if (!$traduire) {
853
+        $traduire = charger_fonction('traduire', 'inc');
854
+        include_spip('inc/lang');
855
+    }
856
+
857
+    // On peut passer explicitement la langue dans le tableau
858
+    // On utilise le même nom de variable que la globale
859
+    if (isset($args['spip_lang'])) {
860
+        $lang = $args['spip_lang'];
861
+        // On l'enleve pour ne pas le passer au remplacement
862
+        unset($args['spip_lang']);
863
+    } // Sinon on prend la langue du contexte
864
+    else {
865
+        $lang = $GLOBALS['spip_lang'];
866
+    }
867
+    $text = $traduire($texte, $lang);
868
+
869
+    if ($text === null || !strlen($text)) {
870
+        if (!$o['force']) {
871
+            return '';
872
+        }
873
+
874
+        $text = $texte;
875
+
876
+        // pour les chaines non traduites, assurer un service minimum
877
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
878
+            $n = strpos($text, ':');
879
+            if ($n !== false) {
880
+                $text = substr($text, $n + 1);
881
+            }
882
+            $text = str_replace('_', ' ', $text);
883
+        }
884
+        $o['class'] = null;
885
+    }
886
+
887
+    return _L($text, $args, $o);
889 888
 }
890 889
 
891 890
 
@@ -912,53 +911,53 @@  discard block
 block discarded – undo
912 911
  *     texte
913 912
  */
914 913
 function _L($text, $args = [], $options = []) {
915
-	$f = $text;
916
-	$defaut_options = [
917
-		'class' => null,
918
-		'sanitize' => true,
919
-	];
920
-	// support de l'ancien argument $class
921
-	if ($options and is_string($options)) {
922
-		$options = ['class' => $options];
923
-	}
924
-	if (is_array($options)) {
925
-		$options += $defaut_options;
926
-	} else {
927
-		$options = $defaut_options;
928
-	}
929
-
930
-	if (is_array($args) and count($args)) {
931
-		if (!function_exists('interdire_scripts')) {
932
-			include_spip('inc/texte');
933
-		}
934
-		if (!function_exists('echapper_html_suspect')) {
935
-			include_spip('inc/texte_mini');
936
-		}
937
-		foreach ($args as $name => $value) {
938
-			if (strpos($text, (string) "@$name@") !== false) {
939
-				if ($options['sanitize']) {
940
-					$value = echapper_html_suspect($value);
941
-					$value = interdire_scripts($value, -1);
942
-				}
943
-				if (!empty($options['class'])) {
944
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
945
-				}
946
-				$text = str_replace("@$name@", $value, $text);
947
-				unset($args[$name]);
948
-			}
949
-		}
950
-		// Si des variables n'ont pas ete inserees, le signaler
951
-		// (chaines de langues pas a jour)
952
-		if ($args) {
953
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
954
-		}
955
-	}
956
-
957
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
958
-		return "<span class='debug-traduction-erreur'>$text</span>";
959
-	} else {
960
-		return $text;
961
-	}
914
+    $f = $text;
915
+    $defaut_options = [
916
+        'class' => null,
917
+        'sanitize' => true,
918
+    ];
919
+    // support de l'ancien argument $class
920
+    if ($options and is_string($options)) {
921
+        $options = ['class' => $options];
922
+    }
923
+    if (is_array($options)) {
924
+        $options += $defaut_options;
925
+    } else {
926
+        $options = $defaut_options;
927
+    }
928
+
929
+    if (is_array($args) and count($args)) {
930
+        if (!function_exists('interdire_scripts')) {
931
+            include_spip('inc/texte');
932
+        }
933
+        if (!function_exists('echapper_html_suspect')) {
934
+            include_spip('inc/texte_mini');
935
+        }
936
+        foreach ($args as $name => $value) {
937
+            if (strpos($text, (string) "@$name@") !== false) {
938
+                if ($options['sanitize']) {
939
+                    $value = echapper_html_suspect($value);
940
+                    $value = interdire_scripts($value, -1);
941
+                }
942
+                if (!empty($options['class'])) {
943
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
944
+                }
945
+                $text = str_replace("@$name@", $value, $text);
946
+                unset($args[$name]);
947
+            }
948
+        }
949
+        // Si des variables n'ont pas ete inserees, le signaler
950
+        // (chaines de langues pas a jour)
951
+        if ($args) {
952
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
953
+        }
954
+    }
955
+
956
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
957
+        return "<span class='debug-traduction-erreur'>$text</span>";
958
+    } else {
959
+        return $text;
960
+    }
962 961
 }
963 962
 
964 963
 
@@ -972,13 +971,13 @@  discard block
 block discarded – undo
972 971
  * @return string
973 972
  */
974 973
 function joli_repertoire($rep) {
975
-	$a = substr($rep, 0, 1);
976
-	if ($a <> '.' and $a <> '/') {
977
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
978
-	}
979
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
974
+    $a = substr($rep, 0, 1);
975
+    if ($a <> '.' and $a <> '/') {
976
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
977
+    }
978
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
980 979
 
981
-	return $rep;
980
+    return $rep;
982 981
 }
983 982
 
984 983
 
@@ -1003,54 +1002,54 @@  discard block
 block discarded – undo
1003 1002
  * @return float|int|string|void
1004 1003
  */
1005 1004
 function spip_timer($t = 'rien', $raw = false) {
1006
-	static $time;
1007
-	$a = time();
1008
-	$b = microtime();
1009
-	// microtime peut contenir les microsecondes et le temps
1010
-	$b = explode(' ', $b);
1011
-	if (count($b) == 2) {
1012
-		$a = end($b);
1013
-	} // plus precis !
1014
-	$b = reset($b);
1015
-	if (!isset($time[$t])) {
1016
-		$time[$t] = $a + $b;
1017
-	} else {
1018
-		$p = ($a + $b - $time[$t]) * 1000;
1019
-		unset($time[$t]);
1005
+    static $time;
1006
+    $a = time();
1007
+    $b = microtime();
1008
+    // microtime peut contenir les microsecondes et le temps
1009
+    $b = explode(' ', $b);
1010
+    if (count($b) == 2) {
1011
+        $a = end($b);
1012
+    } // plus precis !
1013
+    $b = reset($b);
1014
+    if (!isset($time[$t])) {
1015
+        $time[$t] = $a + $b;
1016
+    } else {
1017
+        $p = ($a + $b - $time[$t]) * 1000;
1018
+        unset($time[$t]);
1020 1019
 #			echo "'$p'";exit;
1021
-		if ($raw) {
1022
-			return $p;
1023
-		}
1024
-		if ($p < 1000) {
1025
-			$s = '';
1026
-		} else {
1027
-			$s = sprintf('%d ', $x = floor($p / 1000));
1028
-			$p -= ($x * 1000);
1029
-		}
1020
+        if ($raw) {
1021
+            return $p;
1022
+        }
1023
+        if ($p < 1000) {
1024
+            $s = '';
1025
+        } else {
1026
+            $s = sprintf('%d ', $x = floor($p / 1000));
1027
+            $p -= ($x * 1000);
1028
+        }
1030 1029
 
1031
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1032
-	}
1030
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1031
+    }
1033 1032
 }
1034 1033
 
1035 1034
 
1036 1035
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
1037 1036
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1038 1037
 function spip_touch($fichier, $duree = 0, $touch = true) {
1039
-	if ($duree) {
1040
-		clearstatcache();
1041
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1042
-			return false;
1043
-		}
1044
-	}
1045
-	if ($touch !== false) {
1046
-		if (!@touch($fichier)) {
1047
-			spip_unlink($fichier);
1048
-			@touch($fichier);
1049
-		};
1050
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1051
-	}
1038
+    if ($duree) {
1039
+        clearstatcache();
1040
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1041
+            return false;
1042
+        }
1043
+    }
1044
+    if ($touch !== false) {
1045
+        if (!@touch($fichier)) {
1046
+            spip_unlink($fichier);
1047
+            @touch($fichier);
1048
+        };
1049
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1050
+    }
1052 1051
 
1053
-	return true;
1052
+    return true;
1054 1053
 }
1055 1054
 
1056 1055
 
@@ -1061,11 +1060,11 @@  discard block
 block discarded – undo
1061 1060
  * @uses cron()
1062 1061
  **/
1063 1062
 function action_cron() {
1064
-	include_spip('inc/headers');
1065
-	http_response_code(204); // No Content
1066
-	header('Connection: close');
1067
-	define('_DIRECT_CRON_FORCE', true);
1068
-	cron();
1063
+    include_spip('inc/headers');
1064
+    http_response_code(204); // No Content
1065
+    header('Connection: close');
1066
+    define('_DIRECT_CRON_FORCE', true);
1067
+    cron();
1069 1068
 }
1070 1069
 
1071 1070
 /**
@@ -1081,26 +1080,26 @@  discard block
 block discarded – undo
1081 1080
  *     True si la tache a pu être effectuée
1082 1081
  */
1083 1082
 function cron($taches = [], $taches_old = []) {
1084
-	// si pas en mode cron force, laisser tomber.
1085
-	if (!defined('_DIRECT_CRON_FORCE')) {
1086
-		return false;
1087
-	}
1088
-	if (!is_array($taches)) {
1089
-		$taches = $taches_old;
1090
-	} // compat anciens appels
1091
-	// si taches a inserer en base et base inaccessible, laisser tomber
1092
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1093
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1094
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1095
-	if ($taches and count($taches) and !spip_connect()) {
1096
-		return false;
1097
-	}
1098
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1099
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1100
-		return $genie($taches);
1101
-	}
1102
-
1103
-	return false;
1083
+    // si pas en mode cron force, laisser tomber.
1084
+    if (!defined('_DIRECT_CRON_FORCE')) {
1085
+        return false;
1086
+    }
1087
+    if (!is_array($taches)) {
1088
+        $taches = $taches_old;
1089
+    } // compat anciens appels
1090
+    // si taches a inserer en base et base inaccessible, laisser tomber
1091
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1092
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1093
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1094
+    if ($taches and count($taches) and !spip_connect()) {
1095
+        return false;
1096
+    }
1097
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1098
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1099
+        return $genie($taches);
1100
+    }
1101
+
1102
+    return false;
1104 1103
 }
1105 1104
 
1106 1105
 /**
@@ -1132,17 +1131,17 @@  discard block
 block discarded – undo
1132 1131
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1133 1132
  */
1134 1133
 function job_queue_add(
1135
-	$function,
1136
-	$description,
1137
-	$arguments = [],
1138
-	$file = '',
1139
-	$no_duplicate = false,
1140
-	$time = 0,
1141
-	$priority = 0
1134
+    $function,
1135
+    $description,
1136
+    $arguments = [],
1137
+    $file = '',
1138
+    $no_duplicate = false,
1139
+    $time = 0,
1140
+    $priority = 0
1142 1141
 ) {
1143
-	include_spip('inc/queue');
1142
+    include_spip('inc/queue');
1144 1143
 
1145
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1144
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1146 1145
 }
1147 1146
 
1148 1147
 /**
@@ -1153,9 +1152,9 @@  discard block
 block discarded – undo
1153 1152
  * @return bool
1154 1153
  */
1155 1154
 function job_queue_remove($id_job) {
1156
-	include_spip('inc/queue');
1155
+    include_spip('inc/queue');
1157 1156
 
1158
-	return queue_remove_job($id_job);
1157
+    return queue_remove_job($id_job);
1159 1158
 }
1160 1159
 
1161 1160
 /**
@@ -1168,9 +1167,9 @@  discard block
 block discarded – undo
1168 1167
  *     or an array of simple array to link multiples objet in one time
1169 1168
  */
1170 1169
 function job_queue_link($id_job, $objets) {
1171
-	include_spip('inc/queue');
1170
+    include_spip('inc/queue');
1172 1171
 
1173
-	return queue_link_job($id_job, $objets);
1172
+    return queue_link_job($id_job, $objets);
1174 1173
 }
1175 1174
 
1176 1175
 
@@ -1190,36 +1189,36 @@  discard block
 block discarded – undo
1190 1189
  *  - `null` si la queue n'est pas encore initialisée
1191 1190
  */
1192 1191
 function queue_sleep_time_to_next_job($force = null) {
1193
-	static $queue_next_job_time = -1;
1194
-	if ($force === true) {
1195
-		$queue_next_job_time = -1;
1196
-	} elseif ($force) {
1197
-		$queue_next_job_time = $force;
1198
-	}
1199
-
1200
-	if ($queue_next_job_time == -1) {
1201
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1202
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1203
-		}
1204
-		// utiliser un cache memoire si dispo
1205
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1206
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1207
-		} else {
1208
-			$queue_next_job_time = null;
1209
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1210
-				$queue_next_job_time = intval($contenu);
1211
-			}
1212
-		}
1213
-	}
1214
-
1215
-	if (is_null($queue_next_job_time)) {
1216
-		return null;
1217
-	}
1218
-	if (!$_SERVER['REQUEST_TIME']) {
1219
-		$_SERVER['REQUEST_TIME'] = time();
1220
-	}
1221
-
1222
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1192
+    static $queue_next_job_time = -1;
1193
+    if ($force === true) {
1194
+        $queue_next_job_time = -1;
1195
+    } elseif ($force) {
1196
+        $queue_next_job_time = $force;
1197
+    }
1198
+
1199
+    if ($queue_next_job_time == -1) {
1200
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1201
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1202
+        }
1203
+        // utiliser un cache memoire si dispo
1204
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1205
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1206
+        } else {
1207
+            $queue_next_job_time = null;
1208
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1209
+                $queue_next_job_time = intval($contenu);
1210
+            }
1211
+        }
1212
+    }
1213
+
1214
+    if (is_null($queue_next_job_time)) {
1215
+        return null;
1216
+    }
1217
+    if (!$_SERVER['REQUEST_TIME']) {
1218
+        $_SERVER['REQUEST_TIME'] = time();
1219
+    }
1220
+
1221
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1223 1222
 }
1224 1223
 
1225 1224
 
@@ -1231,11 +1230,11 @@  discard block
 block discarded – undo
1231 1230
  * @return string
1232 1231
  */
1233 1232
 function quote_amp($u) {
1234
-	return preg_replace(
1235
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1236
-		'&amp;',
1237
-		$u
1238
-	);
1233
+    return preg_replace(
1234
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1235
+        '&amp;',
1236
+        $u
1237
+    );
1239 1238
 }
1240 1239
 
1241 1240
 
@@ -1258,27 +1257,27 @@  discard block
 block discarded – undo
1258 1257
  *     Balise HTML `<script>` et son contenu
1259 1258
  **/
1260 1259
 function http_script($script, $src = '', $noscript = '') {
1261
-	static $done = [];
1260
+    static $done = [];
1262 1261
 
1263
-	if ($src && !isset($done[$src])) {
1264
-		$done[$src] = true;
1265
-		$src = find_in_path($src, _JAVASCRIPT);
1266
-		$src = " src='$src'";
1267
-	} else {
1268
-		$src = '';
1269
-	}
1270
-	if ($script) {
1271
-		$script = ("/*<![CDATA[*/\n" .
1272
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1273
-			'/*]]>*/');
1274
-	}
1275
-	if ($noscript) {
1276
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1277
-	}
1262
+    if ($src && !isset($done[$src])) {
1263
+        $done[$src] = true;
1264
+        $src = find_in_path($src, _JAVASCRIPT);
1265
+        $src = " src='$src'";
1266
+    } else {
1267
+        $src = '';
1268
+    }
1269
+    if ($script) {
1270
+        $script = ("/*<![CDATA[*/\n" .
1271
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1272
+            '/*]]>*/');
1273
+    }
1274
+    if ($noscript) {
1275
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1276
+    }
1278 1277
 
1279
-	return ($src or $script or $noscript)
1280
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1281
-		: '';
1278
+    return ($src or $script or $noscript)
1279
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1280
+        : '';
1282 1281
 }
1283 1282
 
1284 1283
 
@@ -1313,7 +1312,7 @@  discard block
 block discarded – undo
1313 1312
  *     texte échappé
1314 1313
  **/
1315 1314
 function texte_script(string $texte): string {
1316
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1315
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1317 1316
 }
1318 1317
 
1319 1318
 
@@ -1350,68 +1349,68 @@  discard block
 block discarded – undo
1350 1349
  *     Liste des chemins, par ordre de priorité.
1351 1350
  **/
1352 1351
 function _chemin($dir_path = null) {
1353
-	static $path_base = null;
1354
-	static $path_full = null;
1355
-	if ($path_base == null) {
1356
-		// Chemin standard depuis l'espace public
1357
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1358
-			_DIR_RACINE . ':' .
1359
-			_DIR_RACINE . 'squelettes-dist/:' .
1360
-			_DIR_RACINE . 'prive/:' .
1361
-			_DIR_RESTREINT;
1362
-		// Ajouter squelettes/
1363
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1364
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1365
-		}
1366
-		foreach (explode(':', $path) as $dir) {
1367
-			if (strlen($dir) and substr($dir, -1) != '/') {
1368
-				$dir .= '/';
1369
-			}
1370
-			$path_base[] = $dir;
1371
-		}
1372
-		$path_full = $path_base;
1373
-		// Et le(s) dossier(s) des squelettes nommes
1374
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1375
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1376
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1377
-			}
1378
-		}
1379
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1380
-	}
1381
-	if ($dir_path === null) {
1382
-		return $path_full;
1383
-	}
1384
-
1385
-	if (is_array($dir_path) or strlen($dir_path)) {
1386
-		$tete = '';
1387
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1388
-			$tete = array_shift($path_base);
1389
-		}
1390
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1391
-		$dirs = array_reverse($dirs);
1392
-		foreach ($dirs as $dir_path) {
1393
-			if (substr($dir_path, -1) != '/') {
1394
-				$dir_path .= '/';
1395
-			}
1396
-			if (!in_array($dir_path, $path_base)) {
1397
-				array_unshift($path_base, $dir_path);
1398
-			}
1399
-		}
1400
-		if (strlen($tete)) {
1401
-			array_unshift($path_base, $tete);
1402
-		}
1403
-	}
1404
-	$path_full = $path_base;
1405
-	// Et le(s) dossier(s) des squelettes nommes
1406
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1407
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1408
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1409
-		}
1410
-	}
1411
-
1412
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1413
-
1414
-	return $path_full;
1352
+    static $path_base = null;
1353
+    static $path_full = null;
1354
+    if ($path_base == null) {
1355
+        // Chemin standard depuis l'espace public
1356
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1357
+            _DIR_RACINE . ':' .
1358
+            _DIR_RACINE . 'squelettes-dist/:' .
1359
+            _DIR_RACINE . 'prive/:' .
1360
+            _DIR_RESTREINT;
1361
+        // Ajouter squelettes/
1362
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1363
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1364
+        }
1365
+        foreach (explode(':', $path) as $dir) {
1366
+            if (strlen($dir) and substr($dir, -1) != '/') {
1367
+                $dir .= '/';
1368
+            }
1369
+            $path_base[] = $dir;
1370
+        }
1371
+        $path_full = $path_base;
1372
+        // Et le(s) dossier(s) des squelettes nommes
1373
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1374
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1375
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1376
+            }
1377
+        }
1378
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1379
+    }
1380
+    if ($dir_path === null) {
1381
+        return $path_full;
1382
+    }
1383
+
1384
+    if (is_array($dir_path) or strlen($dir_path)) {
1385
+        $tete = '';
1386
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1387
+            $tete = array_shift($path_base);
1388
+        }
1389
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1390
+        $dirs = array_reverse($dirs);
1391
+        foreach ($dirs as $dir_path) {
1392
+            if (substr($dir_path, -1) != '/') {
1393
+                $dir_path .= '/';
1394
+            }
1395
+            if (!in_array($dir_path, $path_base)) {
1396
+                array_unshift($path_base, $dir_path);
1397
+            }
1398
+        }
1399
+        if (strlen($tete)) {
1400
+            array_unshift($path_base, $tete);
1401
+        }
1402
+    }
1403
+    $path_full = $path_base;
1404
+    // Et le(s) dossier(s) des squelettes nommes
1405
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1406
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1407
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1408
+        }
1409
+    }
1410
+
1411
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1412
+
1413
+    return $path_full;
1415 1414
 }
1416 1415
 
1417 1416
 /**
@@ -1424,17 +1423,17 @@  discard block
 block discarded – undo
1424 1423
  * @return array Liste de chemins
1425 1424
  **/
1426 1425
 function creer_chemin() {
1427
-	$path_a = _chemin();
1428
-	static $c = '';
1426
+    $path_a = _chemin();
1427
+    static $c = '';
1429 1428
 
1430
-	// on calcule le chemin si le dossier skel a change
1431
-	if ($c != $GLOBALS['dossier_squelettes']) {
1432
-		// assurer le non plantage lors de la montee de version :
1433
-		$c = $GLOBALS['dossier_squelettes'];
1434
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1435
-	}
1429
+    // on calcule le chemin si le dossier skel a change
1430
+    if ($c != $GLOBALS['dossier_squelettes']) {
1431
+        // assurer le non plantage lors de la montee de version :
1432
+        $c = $GLOBALS['dossier_squelettes'];
1433
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1434
+    }
1436 1435
 
1437
-	return $path_a;
1436
+    return $path_a;
1438 1437
 }
1439 1438
 
1440 1439
 
@@ -1446,61 +1445,61 @@  discard block
 block discarded – undo
1446 1445
  * @return string[] Nom des thèmes.
1447 1446
  */
1448 1447
 function lister_themes_prives(): array {
1449
-	static $themes = null;
1450
-	if (is_null($themes)) {
1451
-		// si pas encore definie
1452
-		if (!defined('_SPIP_THEME_PRIVE')) {
1453
-			define('_SPIP_THEME_PRIVE', 'spip');
1454
-		}
1455
-		$themes = [_SPIP_THEME_PRIVE];
1456
-		// Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé
1457
-		// FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp;
1458
-		$prefs = $GLOBALS['visiteur_session']['prefs'] ?? [];
1459
-		if (is_string($prefs) and (stripos($prefs, 'a:') === 0)) {
1460
-			$prefs = unserialize($prefs);
1461
-		} else {
1462
-			$prefs = [];
1463
-		}
1464
-
1465
-		$theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null;
1466
-		if ($theme and $theme !== _SPIP_THEME_PRIVE) {
1467
-			// placer le theme choisi en tete
1468
-			array_unshift($themes, $theme);
1469
-		}
1470
-	}
1471
-
1472
-	return $themes;
1448
+    static $themes = null;
1449
+    if (is_null($themes)) {
1450
+        // si pas encore definie
1451
+        if (!defined('_SPIP_THEME_PRIVE')) {
1452
+            define('_SPIP_THEME_PRIVE', 'spip');
1453
+        }
1454
+        $themes = [_SPIP_THEME_PRIVE];
1455
+        // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé
1456
+        // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp;
1457
+        $prefs = $GLOBALS['visiteur_session']['prefs'] ?? [];
1458
+        if (is_string($prefs) and (stripos($prefs, 'a:') === 0)) {
1459
+            $prefs = unserialize($prefs);
1460
+        } else {
1461
+            $prefs = [];
1462
+        }
1463
+
1464
+        $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null;
1465
+        if ($theme and $theme !== _SPIP_THEME_PRIVE) {
1466
+            // placer le theme choisi en tete
1467
+            array_unshift($themes, $theme);
1468
+        }
1469
+    }
1470
+
1471
+    return $themes;
1473 1472
 }
1474 1473
 
1475 1474
 function find_in_theme($file, $subdir = '', $include = false) {
1476
-	static $themefiles = [];
1477
-	if (isset($themefiles["$subdir$file"])) {
1478
-		return $themefiles["$subdir$file"];
1479
-	}
1480
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1481
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1482
-	if (
1483
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1484
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1485
-		and $f = find_in_theme("$file_svg_generique")
1486
-	) {
1487
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1488
-			return $themefiles["$subdir$file"] = $fsize;
1489
-		}
1490
-		else {
1491
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1492
-		}
1493
-	}
1494
-
1495
-	$themes = lister_themes_prives();
1496
-	foreach ($themes as $theme) {
1497
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1498
-			return $themefiles["$subdir$file"] = $f;
1499
-		}
1500
-	}
1501
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1502
-
1503
-	return $themefiles["$subdir$file"] = '';
1475
+    static $themefiles = [];
1476
+    if (isset($themefiles["$subdir$file"])) {
1477
+        return $themefiles["$subdir$file"];
1478
+    }
1479
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1480
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1481
+    if (
1482
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1483
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1484
+        and $f = find_in_theme("$file_svg_generique")
1485
+    ) {
1486
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1487
+            return $themefiles["$subdir$file"] = $fsize;
1488
+        }
1489
+        else {
1490
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1491
+        }
1492
+    }
1493
+
1494
+    $themes = lister_themes_prives();
1495
+    foreach ($themes as $theme) {
1496
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1497
+            return $themefiles["$subdir$file"] = $f;
1498
+        }
1499
+    }
1500
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1501
+
1502
+    return $themefiles["$subdir$file"] = '';
1504 1503
 }
1505 1504
 
1506 1505
 
@@ -1524,31 +1523,31 @@  discard block
 block discarded – undo
1524 1523
  *     sinon chaîne vide.
1525 1524
  **/
1526 1525
 function chemin_image($icone) {
1527
-	static $icone_renommer;
1528
-	if ($p = strpos($icone, '?')) {
1529
-		$icone = substr($icone, 0, $p);
1530
-	}
1531
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1532
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1533
-		return $icone;
1534
-	}
1535
-
1536
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1537
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1538
-		return $f;
1539
-	}
1540
-	// sinon passer par le module de renommage
1541
-	if (is_null($icone_renommer)) {
1542
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1543
-	}
1544
-	if ($icone_renommer) {
1545
-		[$icone, $fonction] = $icone_renommer($icone, '');
1546
-		if (file_exists($icone)) {
1547
-			return $icone;
1548
-		}
1549
-	}
1550
-
1551
-	return find_in_path($icone, _NOM_IMG_PACK);
1526
+    static $icone_renommer;
1527
+    if ($p = strpos($icone, '?')) {
1528
+        $icone = substr($icone, 0, $p);
1529
+    }
1530
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1531
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1532
+        return $icone;
1533
+    }
1534
+
1535
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1536
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1537
+        return $f;
1538
+    }
1539
+    // sinon passer par le module de renommage
1540
+    if (is_null($icone_renommer)) {
1541
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1542
+    }
1543
+    if ($icone_renommer) {
1544
+        [$icone, $fonction] = $icone_renommer($icone, '');
1545
+        if (file_exists($icone)) {
1546
+            return $icone;
1547
+        }
1548
+    }
1549
+
1550
+    return find_in_path($icone, _NOM_IMG_PACK);
1552 1551
 }
1553 1552
 
1554 1553
 //
@@ -1586,128 +1585,128 @@  discard block
 block discarded – undo
1586 1585
  *     - false : fichier introuvable
1587 1586
  **/
1588 1587
 function find_in_path($file, $dirname = '', $include = false) {
1589
-	static $dirs = [];
1590
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1591
-	static $c = '';
1592
-
1593
-	if (!$file and !strlen($file)) {
1594
-		return false;
1595
-	}
1596
-
1597
-	// on calcule le chemin si le dossier skel a change
1598
-	if ($c != $GLOBALS['dossier_squelettes']) {
1599
-		// assurer le non plantage lors de la montee de version :
1600
-		$c = $GLOBALS['dossier_squelettes'];
1601
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1602
-	}
1603
-
1604
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1605
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1606
-			return false;
1607
-		}
1608
-		if ($include and !isset($inc[$dirname][$file])) {
1609
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1610
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1611
-		}
1612
-
1613
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1614
-	}
1615
-
1616
-	$a = strrpos($file, '/');
1617
-	if ($a !== false) {
1618
-		$dirname .= substr($file, 0, ++$a);
1619
-		$file = substr($file, $a);
1620
-	}
1621
-
1622
-	foreach (creer_chemin() as $dir) {
1623
-		if (!isset($dirs[$a = $dir . $dirname])) {
1624
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1625
-		}
1626
-		if ($dirs[$a]) {
1627
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1628
-				if ($include and !isset($inc[$dirname][$file])) {
1629
-					include_once _ROOT_CWD . $a;
1630
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1631
-				}
1632
-				if (!defined('_SAUVER_CHEMIN')) {
1633
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1634
-					if (is_null($GLOBALS['path_files'])) {
1635
-						return $a;
1636
-					}
1637
-					define('_SAUVER_CHEMIN', true);
1638
-				}
1639
-
1640
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1641
-			}
1642
-		}
1643
-	}
1644
-
1645
-	if ($include) {
1646
-		spip_log("include_spip $dirname$file non trouve");
1647
-		if ($include === 'required') {
1648
-			echo '<pre>',
1649
-			'<strong>Erreur Fatale</strong><br />';
1650
-			if (function_exists('debug_print_backtrace')) {
1651
-				debug_print_backtrace();
1652
-			}
1653
-			echo '</pre>';
1654
-			die("Erreur interne: ne peut inclure $dirname$file");
1655
-		}
1656
-	}
1657
-
1658
-	if (!defined('_SAUVER_CHEMIN')) {
1659
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1660
-		if (is_null($GLOBALS['path_files'])) {
1661
-			return false;
1662
-		}
1663
-		define('_SAUVER_CHEMIN', true);
1664
-	}
1665
-
1666
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1588
+    static $dirs = [];
1589
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1590
+    static $c = '';
1591
+
1592
+    if (!$file and !strlen($file)) {
1593
+        return false;
1594
+    }
1595
+
1596
+    // on calcule le chemin si le dossier skel a change
1597
+    if ($c != $GLOBALS['dossier_squelettes']) {
1598
+        // assurer le non plantage lors de la montee de version :
1599
+        $c = $GLOBALS['dossier_squelettes'];
1600
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1601
+    }
1602
+
1603
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1604
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1605
+            return false;
1606
+        }
1607
+        if ($include and !isset($inc[$dirname][$file])) {
1608
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1609
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1610
+        }
1611
+
1612
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1613
+    }
1614
+
1615
+    $a = strrpos($file, '/');
1616
+    if ($a !== false) {
1617
+        $dirname .= substr($file, 0, ++$a);
1618
+        $file = substr($file, $a);
1619
+    }
1620
+
1621
+    foreach (creer_chemin() as $dir) {
1622
+        if (!isset($dirs[$a = $dir . $dirname])) {
1623
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1624
+        }
1625
+        if ($dirs[$a]) {
1626
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1627
+                if ($include and !isset($inc[$dirname][$file])) {
1628
+                    include_once _ROOT_CWD . $a;
1629
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1630
+                }
1631
+                if (!defined('_SAUVER_CHEMIN')) {
1632
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1633
+                    if (is_null($GLOBALS['path_files'])) {
1634
+                        return $a;
1635
+                    }
1636
+                    define('_SAUVER_CHEMIN', true);
1637
+                }
1638
+
1639
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1640
+            }
1641
+        }
1642
+    }
1643
+
1644
+    if ($include) {
1645
+        spip_log("include_spip $dirname$file non trouve");
1646
+        if ($include === 'required') {
1647
+            echo '<pre>',
1648
+            '<strong>Erreur Fatale</strong><br />';
1649
+            if (function_exists('debug_print_backtrace')) {
1650
+                debug_print_backtrace();
1651
+            }
1652
+            echo '</pre>';
1653
+            die("Erreur interne: ne peut inclure $dirname$file");
1654
+        }
1655
+    }
1656
+
1657
+    if (!defined('_SAUVER_CHEMIN')) {
1658
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1659
+        if (is_null($GLOBALS['path_files'])) {
1660
+            return false;
1661
+        }
1662
+        define('_SAUVER_CHEMIN', true);
1663
+    }
1664
+
1665
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1667 1666
 }
1668 1667
 
1669 1668
 function clear_path_cache() {
1670
-	$GLOBALS['path_files'] = [];
1671
-	spip_unlink(_CACHE_CHEMIN);
1669
+    $GLOBALS['path_files'] = [];
1670
+    spip_unlink(_CACHE_CHEMIN);
1672 1671
 }
1673 1672
 
1674 1673
 function load_path_cache() {
1675
-	// charger le path des plugins
1676
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1677
-		include_once(_CACHE_PLUGINS_PATH);
1678
-	}
1679
-	$GLOBALS['path_files'] = [];
1680
-	// si le visiteur est admin,
1681
-	// on ne recharge pas le cache pour forcer sa mise a jour
1682
-	if (
1683
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1684
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1685
-		// utiliser le cookie est un pis aller qui marche 'en general'
1686
-		// on blinde par un second test au moment de la lecture de la session
1687
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1688
-		// et en ignorant ce cache en cas de recalcul explicite
1689
-		!_request('var_mode')
1690
-	) {
1691
-		// on essaye de lire directement sans verrou pour aller plus vite
1692
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1693
-			// mais si semble corrompu on relit avec un verrou
1694
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1695
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1696
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1697
-					$GLOBALS['path_files'] = [];
1698
-				}
1699
-			}
1700
-		}
1701
-	}
1674
+    // charger le path des plugins
1675
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1676
+        include_once(_CACHE_PLUGINS_PATH);
1677
+    }
1678
+    $GLOBALS['path_files'] = [];
1679
+    // si le visiteur est admin,
1680
+    // on ne recharge pas le cache pour forcer sa mise a jour
1681
+    if (
1682
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1683
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1684
+        // utiliser le cookie est un pis aller qui marche 'en general'
1685
+        // on blinde par un second test au moment de la lecture de la session
1686
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1687
+        // et en ignorant ce cache en cas de recalcul explicite
1688
+        !_request('var_mode')
1689
+    ) {
1690
+        // on essaye de lire directement sans verrou pour aller plus vite
1691
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1692
+            // mais si semble corrompu on relit avec un verrou
1693
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1694
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1695
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1696
+                    $GLOBALS['path_files'] = [];
1697
+                }
1698
+            }
1699
+        }
1700
+    }
1702 1701
 }
1703 1702
 
1704 1703
 function save_path_cache() {
1705
-	if (
1706
-		defined('_SAUVER_CHEMIN')
1707
-		and _SAUVER_CHEMIN
1708
-	) {
1709
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1710
-	}
1704
+    if (
1705
+        defined('_SAUVER_CHEMIN')
1706
+        and _SAUVER_CHEMIN
1707
+    ) {
1708
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1709
+    }
1711 1710
 }
1712 1711
 
1713 1712
 
@@ -1727,33 +1726,33 @@  discard block
 block discarded – undo
1727 1726
  * @return array
1728 1727
  */
1729 1728
 function find_all_in_path($dir, $pattern, $recurs = false) {
1730
-	$liste_fichiers = [];
1731
-	$maxfiles = 10000;
1732
-
1733
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1734
-	// on a pas encore inclus flock.php
1735
-	if (!function_exists('preg_files')) {
1736
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1737
-	}
1738
-
1739
-	// Parcourir le chemin
1740
-	foreach (creer_chemin() as $d) {
1741
-		$f = $d . $dir;
1742
-		if (@is_dir($f)) {
1743
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1744
-			foreach ($liste as $chemin) {
1745
-				$nom = basename($chemin);
1746
-				// ne prendre que les fichiers pas deja trouves
1747
-				// car find_in_path prend le premier qu'il trouve,
1748
-				// les autres sont donc masques
1749
-				if (!isset($liste_fichiers[$nom])) {
1750
-					$liste_fichiers[$nom] = $chemin;
1751
-				}
1752
-			}
1753
-		}
1754
-	}
1755
-
1756
-	return $liste_fichiers;
1729
+    $liste_fichiers = [];
1730
+    $maxfiles = 10000;
1731
+
1732
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1733
+    // on a pas encore inclus flock.php
1734
+    if (!function_exists('preg_files')) {
1735
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1736
+    }
1737
+
1738
+    // Parcourir le chemin
1739
+    foreach (creer_chemin() as $d) {
1740
+        $f = $d . $dir;
1741
+        if (@is_dir($f)) {
1742
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1743
+            foreach ($liste as $chemin) {
1744
+                $nom = basename($chemin);
1745
+                // ne prendre que les fichiers pas deja trouves
1746
+                // car find_in_path prend le premier qu'il trouve,
1747
+                // les autres sont donc masques
1748
+                if (!isset($liste_fichiers[$nom])) {
1749
+                    $liste_fichiers[$nom] = $chemin;
1750
+                }
1751
+            }
1752
+        }
1753
+    }
1754
+
1755
+    return $liste_fichiers;
1757 1756
 }
1758 1757
 
1759 1758
 /**
@@ -1765,17 +1764,17 @@  discard block
 block discarded – undo
1765 1764
  * @return bool
1766 1765
  */
1767 1766
 function autoriser_sans_cookie($nom, $strict = false) {
1768
-	static $autsanscookie = ['install', 'base_repair'];
1767
+    static $autsanscookie = ['install', 'base_repair'];
1769 1768
 
1770
-	if (in_array($nom, $autsanscookie)) {
1771
-		if (test_espace_prive()) {
1772
-			include_spip('base/connect_sql');
1773
-			if (!$strict or !spip_connect()) {
1774
-				return true;
1775
-			}
1776
-		}
1777
-	}
1778
-	return false;
1769
+    if (in_array($nom, $autsanscookie)) {
1770
+        if (test_espace_prive()) {
1771
+            include_spip('base/connect_sql');
1772
+            if (!$strict or !spip_connect()) {
1773
+                return true;
1774
+            }
1775
+        }
1776
+    }
1777
+    return false;
1779 1778
 }
1780 1779
 
1781 1780
 /**
@@ -1785,60 +1784,60 @@  discard block
 block discarded – undo
1785 1784
  * @return string
1786 1785
  */
1787 1786
 function charger_fonction_url(string $quoi, string $type = '') {
1788
-	if ($type === 'defaut') {
1789
-		$objet = objet_type($quoi);
1790
-		if (
1791
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1792
-			// deprecated
1793
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1794
-		) {
1795
-			return $f;
1796
-		}
1797
-		return '';
1798
-	}
1799
-
1800
-	$url_type = $type;
1801
-	if (!$url_type) {
1802
-		$url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1803
-	}
1804
-
1805
-	// inclure le module d'url
1806
-	include_spip('urls/' . $url_type);
1807
-
1808
-	switch ($quoi) {
1809
-		case 'page':
1810
-			if (
1811
-				 function_exists($f = "urls_{$url_type}_generer_url_page")
1812
-				or function_exists($f .= '_dist')
1813
-				// ou une fonction custom utilisateur independante du type d'url
1814
-				or function_exists($f = 'generer_url_page')
1815
-				or function_exists($f .= '_dist')
1816
-			) {
1817
-				return $f;
1818
-			}
1819
-			// pas de compat ancienne version ici, c'est une nouvelle feature
1820
-			return '';
1821
-		case 'objet':
1822
-		case 'decoder':
1823
-		default:
1824
-			$fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1825
-			if (
1826
-				function_exists($f = "urls_{$url_type}_{$fquoi}")
1827
-				or function_exists($f .= '_dist')
1828
-			) {
1829
-				return $f;
1830
-			}
1831
-			// est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1832
-			// c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1833
-			if ($f = charger_fonction($url_type, 'urls', true)) {
1834
-				return $f;
1835
-			}
1836
-			// sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1837
-			if (!$type and $url_type !== 'page') {
1838
-				return charger_fonction_url($quoi, 'page');
1839
-			}
1840
-			return '';
1841
-	}
1787
+    if ($type === 'defaut') {
1788
+        $objet = objet_type($quoi);
1789
+        if (
1790
+            $f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1791
+            // deprecated
1792
+            or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1793
+        ) {
1794
+            return $f;
1795
+        }
1796
+        return '';
1797
+    }
1798
+
1799
+    $url_type = $type;
1800
+    if (!$url_type) {
1801
+        $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1802
+    }
1803
+
1804
+    // inclure le module d'url
1805
+    include_spip('urls/' . $url_type);
1806
+
1807
+    switch ($quoi) {
1808
+        case 'page':
1809
+            if (
1810
+                    function_exists($f = "urls_{$url_type}_generer_url_page")
1811
+                or function_exists($f .= '_dist')
1812
+                // ou une fonction custom utilisateur independante du type d'url
1813
+                or function_exists($f = 'generer_url_page')
1814
+                or function_exists($f .= '_dist')
1815
+            ) {
1816
+                return $f;
1817
+            }
1818
+            // pas de compat ancienne version ici, c'est une nouvelle feature
1819
+            return '';
1820
+        case 'objet':
1821
+        case 'decoder':
1822
+        default:
1823
+            $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1824
+            if (
1825
+                function_exists($f = "urls_{$url_type}_{$fquoi}")
1826
+                or function_exists($f .= '_dist')
1827
+            ) {
1828
+                return $f;
1829
+            }
1830
+            // est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1831
+            // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1832
+            if ($f = charger_fonction($url_type, 'urls', true)) {
1833
+                return $f;
1834
+            }
1835
+            // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1836
+            if (!$type and $url_type !== 'page') {
1837
+                return charger_fonction_url($quoi, 'page');
1838
+            }
1839
+            return '';
1840
+    }
1842 1841
 }
1843 1842
 
1844 1843
 
@@ -1864,48 +1863,48 @@  discard block
 block discarded – undo
1864 1863
  *   url codee ou fonction de decodage
1865 1864
  */
1866 1865
 function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1867
-	if ($public === null) {
1868
-		$public = !test_espace_prive();
1869
-	}
1870
-	$id = intval($id);
1871
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1872
-
1873
-	if (!$public) {
1874
-		if (!$entite) {
1875
-			return '';
1876
-		}
1877
-		if (!function_exists('generer_objet_url_ecrire')) {
1878
-			include_spip('inc/urls');
1879
-		}
1880
-		$res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1881
-	} else {
1882
-		$f = charger_fonction_url('objet', $type ?? '');
1883
-
1884
-		// @deprecated si $entite='', on veut la fonction de passage URL ==> id
1885
-		// @see charger_fonction_url
1886
-		if (!$entite) {
1887
-			return $f;
1888
-		}
1889
-
1890
-		// mais d'abord il faut tester le cas des urls sur une
1891
-		// base distante
1892
-		if (
1893
-			$connect
1894
-			and $g = charger_fonction('connect', 'urls', true)
1895
-		) {
1896
-			$f = $g;
1897
-		}
1898
-
1899
-		$res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1900
-	}
1901
-	if ($res) {
1902
-		return $res;
1903
-	}
1904
-
1905
-	// On a ete gentil mais la ....
1906
-	spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1907
-
1908
-	return '';
1866
+    if ($public === null) {
1867
+        $public = !test_espace_prive();
1868
+    }
1869
+    $id = intval($id);
1870
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1871
+
1872
+    if (!$public) {
1873
+        if (!$entite) {
1874
+            return '';
1875
+        }
1876
+        if (!function_exists('generer_objet_url_ecrire')) {
1877
+            include_spip('inc/urls');
1878
+        }
1879
+        $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1880
+    } else {
1881
+        $f = charger_fonction_url('objet', $type ?? '');
1882
+
1883
+        // @deprecated si $entite='', on veut la fonction de passage URL ==> id
1884
+        // @see charger_fonction_url
1885
+        if (!$entite) {
1886
+            return $f;
1887
+        }
1888
+
1889
+        // mais d'abord il faut tester le cas des urls sur une
1890
+        // base distante
1891
+        if (
1892
+            $connect
1893
+            and $g = charger_fonction('connect', 'urls', true)
1894
+        ) {
1895
+            $f = $g;
1896
+        }
1897
+
1898
+        $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1899
+    }
1900
+    if ($res) {
1901
+        return $res;
1902
+    }
1903
+
1904
+    // On a ete gentil mais la ....
1905
+    spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1906
+
1907
+    return '';
1909 1908
 }
1910 1909
 
1911 1910
 /**
@@ -1913,10 +1912,10 @@  discard block
 block discarded – undo
1913 1912
  * @see generer_objet_url
1914 1913
  */
1915 1914
 function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1916
-	if ($public and is_string($public)) {
1917
-		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1918
-	}
1919
-	return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1915
+    if ($public and is_string($public)) {
1916
+        return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1917
+    }
1918
+    return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1920 1919
 }
1921 1920
 
1922 1921
 /**
@@ -1928,19 +1927,19 @@  discard block
 block discarded – undo
1928 1927
  * @return string
1929 1928
  */
1930 1929
 function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string {
1931
-	$id = intval($id);
1932
-	$exec = objet_info($entite, 'url_edit');
1933
-	$url = generer_url_ecrire($exec, $args);
1934
-	if (intval($id)) {
1935
-		$url = parametre_url($url, id_table_objet($entite), $id);
1936
-	} else {
1937
-		$url = parametre_url($url, 'new', 'oui');
1938
-	}
1939
-	if ($ancre) {
1940
-		$url = ancre_url($url, $ancre);
1941
-	}
1930
+    $id = intval($id);
1931
+    $exec = objet_info($entite, 'url_edit');
1932
+    $url = generer_url_ecrire($exec, $args);
1933
+    if (intval($id)) {
1934
+        $url = parametre_url($url, id_table_objet($entite), $id);
1935
+    } else {
1936
+        $url = parametre_url($url, 'new', 'oui');
1937
+    }
1938
+    if ($ancre) {
1939
+        $url = ancre_url($url, $ancre);
1940
+    }
1942 1941
 
1943
-	return $url;
1942
+    return $url;
1944 1943
 }
1945 1944
 
1946 1945
 /**
@@ -1948,18 +1947,18 @@  discard block
 block discarded – undo
1948 1947
  * @see generer_objet_url_ecrire_edit
1949 1948
  */
1950 1949
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1951
-	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1950
+    return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1952 1951
 }
1953 1952
 
1954 1953
 
1955 1954
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1956
-	include_spip('base/connect_sql');
1957
-	$id_type = id_table_objet($entite, $public);
1955
+    include_spip('base/connect_sql');
1956
+    $id_type = id_table_objet($entite, $public);
1958 1957
 
1959
-	return _DIR_RACINE . get_spip_script('./')
1960
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1961
-	. (!$args ? '' : "&$args")
1962
-	. (!$ancre ? '' : "#$ancre");
1958
+    return _DIR_RACINE . get_spip_script('./')
1959
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1960
+    . (!$args ? '' : "&$args")
1961
+    . (!$ancre ? '' : "#$ancre");
1963 1962
 }
1964 1963
 
1965 1964
 
@@ -1970,18 +1969,18 @@  discard block
 block discarded – undo
1970 1969
  * @return string
1971 1970
  */
1972 1971
 function urlencode_1738($url) {
1973
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1974
-		$uri = '';
1975
-		for ($i = 0; $i < strlen($url); $i++) {
1976
-			if (ord($a = $url[$i]) > 127) {
1977
-				$a = rawurlencode($a);
1978
-			}
1979
-			$uri .= $a;
1980
-		}
1981
-		$url = $uri;
1982
-	}
1972
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1973
+        $uri = '';
1974
+        for ($i = 0; $i < strlen($url); $i++) {
1975
+            if (ord($a = $url[$i]) > 127) {
1976
+                $a = rawurlencode($a);
1977
+            }
1978
+            $uri .= $a;
1979
+        }
1980
+        $url = $uri;
1981
+    }
1983 1982
 
1984
-	return quote_amp($url);
1983
+    return quote_amp($url);
1985 1984
 }
1986 1985
 
1987 1986
 /**
@@ -1997,14 +1996,14 @@  discard block
 block discarded – undo
1997 1996
  * @return string
1998 1997
  */
1999 1998
 function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
2000
-	$id = intval($id);
2001
-	$h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
2002
-	if (!preg_match(',^\w+:,', $h)) {
2003
-		include_spip('inc/filtres_mini');
2004
-		$h = url_absolue($h);
2005
-	}
1999
+    $id = intval($id);
2000
+    $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
2001
+    if (!preg_match(',^\w+:,', $h)) {
2002
+        include_spip('inc/filtres_mini');
2003
+        $h = url_absolue($h);
2004
+    }
2006 2005
 
2007
-	return $h;
2006
+    return $h;
2008 2007
 }
2009 2008
 
2010 2009
 /**
@@ -2012,7 +2011,7 @@  discard block
 block discarded – undo
2012 2011
  * @see  generer_objet_url_absolue
2013 2012
  */
2014 2013
 function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) {
2015
-	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
2014
+    return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
2016 2015
 }
2017 2016
 
2018 2017
 
@@ -2028,11 +2027,11 @@  discard block
 block discarded – undo
2028 2027
  *     true si la valeur est considérée active ; false sinon.
2029 2028
  **/
2030 2029
 function test_valeur_serveur($truc) {
2031
-	if (!$truc) {
2032
-		return false;
2033
-	}
2030
+    if (!$truc) {
2031
+        return false;
2032
+    }
2034 2033
 
2035
-	return (strtolower($truc) !== 'off');
2034
+    return (strtolower($truc) !== 'off');
2036 2035
 }
2037 2036
 
2038 2037
 //
@@ -2060,89 +2059,89 @@  discard block
 block discarded – undo
2060 2059
  */
2061 2060
 function url_de_base($profondeur = null) {
2062 2061
 
2063
-	static $url = [];
2064
-	if (is_array($profondeur)) {
2065
-		return $url = $profondeur;
2066
-	}
2067
-	if ($profondeur === false) {
2068
-		return $url;
2069
-	}
2070
-
2071
-	if (is_null($profondeur)) {
2072
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2073
-	}
2074
-
2075
-	if (isset($url[$profondeur])) {
2076
-		return $url[$profondeur];
2077
-	}
2078
-
2079
-	$http = 'http';
2080
-
2081
-	if (
2082
-		isset($_SERVER['SCRIPT_URI'])
2083
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2084
-	) {
2085
-		$http = 'https';
2086
-	} elseif (
2087
-		isset($_SERVER['HTTPS'])
2088
-		and test_valeur_serveur($_SERVER['HTTPS'])
2089
-	) {
2090
-		$http = 'https';
2091
-	}
2092
-
2093
-	// note : HTTP_HOST contient le :port si necessaire
2094
-	if ($host = $_SERVER['HTTP_HOST'] ?? null) {
2095
-		// Filtrer $host pour proteger d'attaques d'entete HTTP
2096
-		$host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
2097
-	}
2098
-
2099
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2100
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2101
-		$host = $GLOBALS['meta']['adresse_site'];
2102
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2103
-			$http = $scheme;
2104
-			$host = str_replace("{$scheme}://", '', $host);
2105
-		}
2106
-	}
2107
-	if (
2108
-		isset($_SERVER['SERVER_PORT'])
2109
-		and $port = $_SERVER['SERVER_PORT']
2110
-		and strpos($host, ':') == false
2111
-	) {
2112
-		if (!defined('_PORT_HTTP_STANDARD')) {
2113
-			define('_PORT_HTTP_STANDARD', '80');
2114
-		}
2115
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2116
-			define('_PORT_HTTPS_STANDARD', '443');
2117
-		}
2118
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2119
-			$host .= ":$port";
2120
-		}
2121
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2122
-			$host .= ":$port";
2123
-		}
2124
-	}
2125
-
2126
-	if (!$GLOBALS['REQUEST_URI']) {
2127
-		if (isset($_SERVER['REQUEST_URI'])) {
2128
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2129
-		} else {
2130
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2131
-			if (
2132
-				!empty($_SERVER['QUERY_STRING'])
2133
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2134
-			) {
2135
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2136
-			}
2137
-		}
2138
-	}
2139
-
2140
-	// Et nettoyer l'url
2141
-	$GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
2142
-
2143
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2144
-
2145
-	return $url[$profondeur];
2062
+    static $url = [];
2063
+    if (is_array($profondeur)) {
2064
+        return $url = $profondeur;
2065
+    }
2066
+    if ($profondeur === false) {
2067
+        return $url;
2068
+    }
2069
+
2070
+    if (is_null($profondeur)) {
2071
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2072
+    }
2073
+
2074
+    if (isset($url[$profondeur])) {
2075
+        return $url[$profondeur];
2076
+    }
2077
+
2078
+    $http = 'http';
2079
+
2080
+    if (
2081
+        isset($_SERVER['SCRIPT_URI'])
2082
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2083
+    ) {
2084
+        $http = 'https';
2085
+    } elseif (
2086
+        isset($_SERVER['HTTPS'])
2087
+        and test_valeur_serveur($_SERVER['HTTPS'])
2088
+    ) {
2089
+        $http = 'https';
2090
+    }
2091
+
2092
+    // note : HTTP_HOST contient le :port si necessaire
2093
+    if ($host = $_SERVER['HTTP_HOST'] ?? null) {
2094
+        // Filtrer $host pour proteger d'attaques d'entete HTTP
2095
+        $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
2096
+    }
2097
+
2098
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2099
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2100
+        $host = $GLOBALS['meta']['adresse_site'];
2101
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2102
+            $http = $scheme;
2103
+            $host = str_replace("{$scheme}://", '', $host);
2104
+        }
2105
+    }
2106
+    if (
2107
+        isset($_SERVER['SERVER_PORT'])
2108
+        and $port = $_SERVER['SERVER_PORT']
2109
+        and strpos($host, ':') == false
2110
+    ) {
2111
+        if (!defined('_PORT_HTTP_STANDARD')) {
2112
+            define('_PORT_HTTP_STANDARD', '80');
2113
+        }
2114
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2115
+            define('_PORT_HTTPS_STANDARD', '443');
2116
+        }
2117
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2118
+            $host .= ":$port";
2119
+        }
2120
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2121
+            $host .= ":$port";
2122
+        }
2123
+    }
2124
+
2125
+    if (!$GLOBALS['REQUEST_URI']) {
2126
+        if (isset($_SERVER['REQUEST_URI'])) {
2127
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2128
+        } else {
2129
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2130
+            if (
2131
+                !empty($_SERVER['QUERY_STRING'])
2132
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2133
+            ) {
2134
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2135
+            }
2136
+        }
2137
+    }
2138
+
2139
+    // Et nettoyer l'url
2140
+    $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
2141
+
2142
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2143
+
2144
+    return $url[$profondeur];
2146 2145
 }
2147 2146
 
2148 2147
 /**
@@ -2155,26 +2154,26 @@  discard block
 block discarded – undo
2155 2154
  * @return string
2156 2155
  */
2157 2156
 function url_de_($http, $host, $request, $prof = 0) {
2158
-	$prof = max($prof, 0);
2157
+    $prof = max($prof, 0);
2159 2158
 
2160
-	$myself = ltrim($request, '/');
2161
-	# supprimer la chaine de GET
2162
-	[$myself] = explode('?', $myself);
2163
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2164
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2165
-	if (strpos($myself, '://') !== false) {
2166
-		$myself = explode('://', $myself);
2167
-		array_shift($myself);
2168
-		$myself = implode('://', $myself);
2169
-		$myself = explode('/', $myself);
2170
-		array_shift($myself);
2171
-		$myself = implode('/', $myself);
2172
-	}
2173
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2159
+    $myself = ltrim($request, '/');
2160
+    # supprimer la chaine de GET
2161
+    [$myself] = explode('?', $myself);
2162
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2163
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2164
+    if (strpos($myself, '://') !== false) {
2165
+        $myself = explode('://', $myself);
2166
+        array_shift($myself);
2167
+        $myself = implode('://', $myself);
2168
+        $myself = explode('/', $myself);
2169
+        array_shift($myself);
2170
+        $myself = implode('/', $myself);
2171
+    }
2172
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2174 2173
 
2175
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2174
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2176 2175
 
2177
-	return $url;
2176
+    return $url;
2178 2177
 }
2179 2178
 
2180 2179
 
@@ -2209,26 +2208,26 @@  discard block
 block discarded – undo
2209 2208
  * @return string URL
2210 2209
  **/
2211 2210
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2212
-	$script ??= '';
2213
-	if (!$rel) {
2214
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2215
-	} else {
2216
-		if (!is_string($rel)) {
2217
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2218
-		}
2219
-	}
2220
-
2221
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2222
-	if ($script and ($script <> 'accueil' or $rel)) {
2223
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2224
-	} elseif ($args) {
2225
-		$args = "?$args";
2226
-	}
2227
-	if ($ancre) {
2228
-		$args .= "#$ancre";
2229
-	}
2230
-
2231
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2211
+    $script ??= '';
2212
+    if (!$rel) {
2213
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2214
+    } else {
2215
+        if (!is_string($rel)) {
2216
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2217
+        }
2218
+    }
2219
+
2220
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
2221
+    if ($script and ($script <> 'accueil' or $rel)) {
2222
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2223
+    } elseif ($args) {
2224
+        $args = "?$args";
2225
+    }
2226
+    if ($ancre) {
2227
+        $args .= "#$ancre";
2228
+    }
2229
+
2230
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2232 2231
 }
2233 2232
 
2234 2233
 //
@@ -2250,15 +2249,15 @@  discard block
 block discarded – undo
2250 2249
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2251 2250
  **/
2252 2251
 function get_spip_script($default = '') {
2253
-	if (!defined('_SPIP_SCRIPT')) {
2254
-		return 'spip.php';
2255
-	}
2256
-	# cas define('_SPIP_SCRIPT', '');
2257
-	if (_SPIP_SCRIPT) {
2258
-		return _SPIP_SCRIPT;
2259
-	} else {
2260
-		return $default;
2261
-	}
2252
+    if (!defined('_SPIP_SCRIPT')) {
2253
+        return 'spip.php';
2254
+    }
2255
+    # cas define('_SPIP_SCRIPT', '');
2256
+    if (_SPIP_SCRIPT) {
2257
+        return _SPIP_SCRIPT;
2258
+    } else {
2259
+        return $default;
2260
+    }
2262 2261
 }
2263 2262
 
2264 2263
 /**
@@ -2287,45 +2286,45 @@  discard block
 block discarded – undo
2287 2286
  * @return string URL
2288 2287
  **/
2289 2288
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2290
-	// si le script est une action (spip_pass, spip_inscription),
2291
-	// standardiser vers la nouvelle API
2292
-
2293
-	if (is_array($args)) {
2294
-		$args = http_build_query($args);
2295
-	}
2296
-
2297
-	$url = '';
2298
-	if ($f = charger_fonction_url('page')) {
2299
-		$url = $f($script, $args);
2300
-		if ($url and !$rel) {
2301
-			include_spip('inc/filtres_mini');
2302
-			$url = url_absolue($url);
2303
-		}
2304
-	}
2305
-	if (!$url) {
2306
-		if (!$action) {
2307
-			$action = get_spip_script();
2308
-		}
2309
-		if ($script) {
2310
-			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2311
-		}
2312
-		if ($args) {
2313
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2314
-		}
2315
-		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2316
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2317
-	}
2318
-
2319
-	if (!$no_entities) {
2320
-		$url = quote_amp($url);
2321
-	}
2322
-
2323
-	return $url;
2289
+    // si le script est une action (spip_pass, spip_inscription),
2290
+    // standardiser vers la nouvelle API
2291
+
2292
+    if (is_array($args)) {
2293
+        $args = http_build_query($args);
2294
+    }
2295
+
2296
+    $url = '';
2297
+    if ($f = charger_fonction_url('page')) {
2298
+        $url = $f($script, $args);
2299
+        if ($url and !$rel) {
2300
+            include_spip('inc/filtres_mini');
2301
+            $url = url_absolue($url);
2302
+        }
2303
+    }
2304
+    if (!$url) {
2305
+        if (!$action) {
2306
+            $action = get_spip_script();
2307
+        }
2308
+        if ($script) {
2309
+            $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2310
+        }
2311
+        if ($args) {
2312
+            $action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2313
+        }
2314
+        // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2315
+        $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2316
+    }
2317
+
2318
+    if (!$no_entities) {
2319
+        $url = quote_amp($url);
2320
+    }
2321
+
2322
+    return $url;
2324 2323
 }
2325 2324
 
2326 2325
 function generer_url_prive($script, $args = '', $no_entities = false) {
2327 2326
 
2328
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2327
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2329 2328
 }
2330 2329
 
2331 2330
 // Pour les formulaires en methode POST,
@@ -2350,19 +2349,19 @@  discard block
 block discarded – undo
2350 2349
  **/
2351 2350
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2352 2351
 
2353
-	$script1 = explode('&', $script);
2354
-	$script1 = reset($script1);
2352
+    $script1 = explode('&', $script);
2353
+    $script1 = reset($script1);
2355 2354
 
2356
-	return "<form action='"
2357
-	. ($script ? generer_url_ecrire($script) : '')
2358
-	. "' "
2359
-	. ($atts ?: " method='post'")
2360
-	. "><div>\n"
2361
-	. "<input type='hidden' name='exec' value='$script1' />"
2362
-	. $corps
2363
-	. (!$submit ? '' :
2364
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2365
-	. "</div></form>\n";
2355
+    return "<form action='"
2356
+    . ($script ? generer_url_ecrire($script) : '')
2357
+    . "' "
2358
+    . ($atts ?: " method='post'")
2359
+    . "><div>\n"
2360
+    . "<input type='hidden' name='exec' value='$script1' />"
2361
+    . $corps
2362
+    . (!$submit ? '' :
2363
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2364
+    . "</div></form>\n";
2366 2365
 }
2367 2366
 
2368 2367
 /**
@@ -2379,22 +2378,22 @@  discard block
 block discarded – undo
2379 2378
  * @return string
2380 2379
  */
2381 2380
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2382
-	// si l'on est dans l'espace prive, on garde dans l'url
2383
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2384
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2385
-	$h = (_DIR_RACINE and !$public)
2386
-		? generer_url_ecrire(_request('exec'))
2387
-		: generer_url_public();
2381
+    // si l'on est dans l'espace prive, on garde dans l'url
2382
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2383
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2384
+    $h = (_DIR_RACINE and !$public)
2385
+        ? generer_url_ecrire(_request('exec'))
2386
+        : generer_url_public();
2388 2387
 
2389
-	return "\n<form action='" .
2390
-	$h .
2391
-	"'" .
2392
-	$atts .
2393
-	">\n" .
2394
-	'<div>' .
2395
-	"\n<input type='hidden' name='action' value='$script' />" .
2396
-	$corps .
2397
-	'</div></form>';
2388
+    return "\n<form action='" .
2389
+    $h .
2390
+    "'" .
2391
+    $atts .
2392
+    ">\n" .
2393
+    '<div>' .
2394
+    "\n<input type='hidden' name='action' value='$script' />" .
2395
+    $corps .
2396
+    '</div></form>';
2398 2397
 }
2399 2398
 
2400 2399
 /**
@@ -2413,22 +2412,22 @@  discard block
 block discarded – undo
2413 2412
  *     URL
2414 2413
  */
2415 2414
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2416
-	// si l'on est dans l'espace prive, on garde dans l'url
2417
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2418
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2419
-	$url = (_DIR_RACINE and !$public)
2420
-		? generer_url_ecrire(_request('exec'))
2421
-		: generer_url_public('', '', false, false);
2422
-	$url = parametre_url($url, 'action', $script);
2423
-	if ($args) {
2424
-		$url .= quote_amp('&' . $args);
2425
-	}
2415
+    // si l'on est dans l'espace prive, on garde dans l'url
2416
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2417
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2418
+    $url = (_DIR_RACINE and !$public)
2419
+        ? generer_url_ecrire(_request('exec'))
2420
+        : generer_url_public('', '', false, false);
2421
+    $url = parametre_url($url, 'action', $script);
2422
+    if ($args) {
2423
+        $url .= quote_amp('&' . $args);
2424
+    }
2426 2425
 
2427
-	if ($no_entities) {
2428
-		$url = str_replace('&amp;', '&', $url);
2429
-	}
2426
+    if ($no_entities) {
2427
+        $url = str_replace('&amp;', '&', $url);
2428
+    }
2430 2429
 
2431
-	return $url;
2430
+    return $url;
2432 2431
 }
2433 2432
 
2434 2433
 
@@ -2447,23 +2446,23 @@  discard block
 block discarded – undo
2447 2446
  *     URL
2448 2447
  */
2449 2448
 function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
2450
-	if (is_null($public)) {
2451
-		$public = (_DIR_RACINE ? false : '');
2452
-	}
2453
-	if (substr($script, -4) !== '.api') {
2454
-		$script .= '.api';
2455
-	}
2456
-	$url =
2457
-		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2458
-	. $script . '/'
2459
-	. ($path ? trim($path, '/') : '')
2460
-	. ($args ? '?' . quote_amp($args) : '');
2449
+    if (is_null($public)) {
2450
+        $public = (_DIR_RACINE ? false : '');
2451
+    }
2452
+    if (substr($script, -4) !== '.api') {
2453
+        $script .= '.api';
2454
+    }
2455
+    $url =
2456
+        (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2457
+    . $script . '/'
2458
+    . ($path ? trim($path, '/') : '')
2459
+    . ($args ? '?' . quote_amp($args) : '');
2461 2460
 
2462
-	if ($no_entities) {
2463
-		$url = str_replace('&amp;', '&', $url);
2464
-	}
2461
+    if ($no_entities) {
2462
+        $url = str_replace('&amp;', '&', $url);
2463
+    }
2465 2464
 
2466
-	return $url;
2465
+    return $url;
2467 2466
 }
2468 2467
 
2469 2468
 
@@ -2476,8 +2475,8 @@  discard block
 block discarded – undo
2476 2475
  * @param string $ta Répertoire temporaire accessible
2477 2476
  */
2478 2477
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2479
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2480
-	spip_initialisation_suite();
2478
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2479
+    spip_initialisation_suite();
2481 2480
 }
2482 2481
 
2483 2482
 /**
@@ -2497,315 +2496,315 @@  discard block
 block discarded – undo
2497 2496
  * @param string $ta Répertoire temporaire accessible
2498 2497
  */
2499 2498
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2500
-	static $too_late = 0;
2501
-	if ($too_late++) {
2502
-		return;
2503
-	}
2504
-
2505
-	// Declaration des repertoires
2506
-
2507
-	// le nom du repertoire plugins/ activables/desactivables
2508
-	if (!defined('_DIR_PLUGINS')) {
2509
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2510
-	}
2511
-
2512
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2513
-	if (!defined('_DIR_PLUGINS_DIST')) {
2514
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2515
-	}
2516
-
2517
-	// le nom du repertoire des librairies
2518
-	if (!defined('_DIR_LIB')) {
2519
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2520
-	}
2521
-
2522
-	// répertoire des libs via Composer
2523
-	if (!defined('_DIR_VENDOR')) {
2524
-		define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
2525
-	}
2526
-
2527
-	if (!defined('_DIR_IMG')) {
2528
-		define('_DIR_IMG', $pa);
2529
-	}
2530
-	if (!defined('_DIR_LOGOS')) {
2531
-		define('_DIR_LOGOS', $pa);
2532
-	}
2533
-	if (!defined('_DIR_IMG_ICONES')) {
2534
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2535
-	}
2536
-
2537
-	if (!defined('_DIR_DUMP')) {
2538
-		define('_DIR_DUMP', $ti . 'dump/');
2539
-	}
2540
-	if (!defined('_DIR_SESSIONS')) {
2541
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2542
-	}
2543
-	if (!defined('_DIR_TRANSFERT')) {
2544
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2545
-	}
2546
-	if (!defined('_DIR_CACHE')) {
2547
-		define('_DIR_CACHE', $ti . 'cache/');
2548
-	}
2549
-	if (!defined('_DIR_CACHE_XML')) {
2550
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2551
-	}
2552
-	if (!defined('_DIR_SKELS')) {
2553
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2554
-	}
2555
-	if (!defined('_DIR_AIDE')) {
2556
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2557
-	}
2558
-	if (!defined('_DIR_TMP')) {
2559
-		define('_DIR_TMP', $ti);
2560
-	}
2561
-
2562
-	if (!defined('_DIR_VAR')) {
2563
-		define('_DIR_VAR', $ta);
2564
-	}
2565
-
2566
-	if (!defined('_DIR_ETC')) {
2567
-		define('_DIR_ETC', $pi);
2568
-	}
2569
-	if (!defined('_DIR_CONNECT')) {
2570
-		define('_DIR_CONNECT', $pi);
2571
-	}
2572
-	if (!defined('_DIR_CHMOD')) {
2573
-		define('_DIR_CHMOD', $pi);
2574
-	}
2575
-
2576
-	if (!isset($GLOBALS['test_dirs'])) {
2577
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2578
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2579
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2580
-	}
2581
-
2582
-	// Declaration des fichiers
2583
-
2584
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2585
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2586
-	}
2587
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2588
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2589
-	}
2590
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2591
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2592
-	}
2593
-	if (!defined('_CACHE_PIPELINES')) {
2594
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2595
-	}
2596
-	if (!defined('_CACHE_CHEMIN')) {
2597
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2598
-	}
2599
-
2600
-	# attention .php obligatoire pour ecrire_fichier_securise
2601
-	if (!defined('_FILE_META')) {
2602
-		define('_FILE_META', $ti . 'meta_cache.php');
2603
-	}
2604
-	if (!defined('_DIR_LOG')) {
2605
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2606
-	}
2607
-	if (!defined('_FILE_LOG')) {
2608
-		define('_FILE_LOG', 'spip');
2609
-	}
2610
-	if (!defined('_FILE_LOG_SUFFIX')) {
2611
-		define('_FILE_LOG_SUFFIX', '.log');
2612
-	}
2613
-
2614
-	// Le fichier de connexion a la base de donnees
2615
-	// tient compte des anciennes versions (inc_connect...)
2616
-	if (!defined('_FILE_CONNECT_INS')) {
2617
-		define('_FILE_CONNECT_INS', 'connect');
2618
-	}
2619
-	if (!defined('_FILE_CONNECT')) {
2620
-		define(
2621
-			'_FILE_CONNECT',
2622
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2623
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2624
-			: false))
2625
-		);
2626
-	}
2627
-
2628
-	// Le fichier de reglages des droits
2629
-	if (!defined('_FILE_CHMOD_INS')) {
2630
-		define('_FILE_CHMOD_INS', 'chmod');
2631
-	}
2632
-	if (!defined('_FILE_CHMOD')) {
2633
-		define(
2634
-			'_FILE_CHMOD',
2635
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2636
-			: false)
2637
-		);
2638
-	}
2639
-
2640
-	if (!defined('_FILE_LDAP')) {
2641
-		define('_FILE_LDAP', 'ldap.php');
2642
-	}
2643
-
2644
-	if (!defined('_FILE_TMP_SUFFIX')) {
2645
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2646
-	}
2647
-	if (!defined('_FILE_CONNECT_TMP')) {
2648
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2649
-	}
2650
-	if (!defined('_FILE_CHMOD_TMP')) {
2651
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2652
-	}
2653
-
2654
-	// Definition des droits d'acces en ecriture
2655
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2656
-		include_once _FILE_CHMOD;
2657
-	}
2658
-
2659
-	// Se mefier des fichiers mal remplis!
2660
-	if (!defined('_SPIP_CHMOD')) {
2661
-		define('_SPIP_CHMOD', 0777);
2662
-	}
2663
-
2664
-	if (!defined('_DEFAULT_CHARSET')) {
2665
-		/** Le charset par défaut lors de l'installation */
2666
-		define('_DEFAULT_CHARSET', 'utf-8');
2667
-	}
2668
-	if (!defined('_ROOT_PLUGINS')) {
2669
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2670
-	}
2671
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2672
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2673
-	}
2674
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2675
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2676
-	}
2677
-
2678
-	// La taille des Log
2679
-	if (!defined('_MAX_LOG')) {
2680
-		define('_MAX_LOG', 100);
2681
-	}
2682
-
2683
-	// Sommes-nous dans l'empire du Mal ?
2684
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2685
-	if (isset($_SERVER['SERVER_SOFTWARE']) and str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) {
2686
-		if (!defined('_OS_SERVEUR')) {
2687
-			define('_OS_SERVEUR', 'windows');
2688
-		}
2689
-		if (!defined('_SPIP_LOCK_MODE')) {
2690
-			define('_SPIP_LOCK_MODE', 1);
2691
-		} // utiliser le flock php
2692
-	} else {
2693
-		if (!defined('_OS_SERVEUR')) {
2694
-			define('_OS_SERVEUR', '');
2695
-		}
2696
-		if (!defined('_SPIP_LOCK_MODE')) {
2697
-			define('_SPIP_LOCK_MODE', 1);
2698
-		} // utiliser le flock php
2699
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2700
-	}
2701
-
2702
-	// Langue par defaut
2703
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2704
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2705
-	}
2706
-
2707
-	//
2708
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2709
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2710
-	// pour le rendre surchargeable, on va provoquer un reecriture
2711
-	// systematique du noyau ou une baisse de perfs => a etudier)
2712
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2713
-
2714
-	// charger tout de suite le path et son cache
2715
-	load_path_cache();
2716
-
2717
-	// *********** traiter les variables ************
2718
-
2719
-	//
2720
-	// Securite
2721
-	//
2722
-
2723
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2724
-	if (isset($_REQUEST['GLOBALS'])) {
2725
-		die();
2726
-	}
2727
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2728
-	spip_desinfecte($_GET);
2729
-	spip_desinfecte($_POST);
2730
-	spip_desinfecte($_COOKIE);
2731
-	spip_desinfecte($_REQUEST);
2732
-
2733
-	// appliquer le cookie_prefix
2734
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2735
-		include_spip('inc/cookie');
2736
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2737
-	}
2738
-
2739
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2740
-	if (isset($_SERVER['REQUEST_URI'])) {
2741
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2742
-	} else {
2743
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2744
-		if (
2745
-			!empty($_SERVER['QUERY_STRING'])
2746
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2747
-		) {
2748
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2749
-		}
2750
-	}
2751
-
2752
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2753
-	if (!defined('_RENOUVELLE_ALEA')) {
2754
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2755
-	}
2756
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2757
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2758
-	}
2759
-
2760
-	// charger les meta si possible et renouveller l'alea au besoin
2761
-	// charge aussi effacer_meta et ecrire_meta
2762
-	$inc_meta = charger_fonction('meta', 'inc');
2763
-	$inc_meta();
2764
-
2765
-	// nombre de repertoires depuis la racine
2766
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2767
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2768
-	// le calcul est faux)
2769
-	if (!_DIR_RESTREINT) {
2770
-		$GLOBALS['profondeur_url'] = 1;
2771
-	} else {
2772
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2773
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2774
-		if (
2775
-			!$uri_ref
2776
-			// si on est appele avec un autre ti, on est sans doute en mutu
2777
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2778
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2779
-			// s'en remettre a l'adresse du site. alea jacta est.
2780
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2781
-		) {
2782
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2783
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2784
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2785
-			} else {
2786
-				$uri_ref = '';
2787
-			}
2788
-		}
2789
-		if (!$uri or !$uri_ref) {
2790
-			$GLOBALS['profondeur_url'] = 0;
2791
-		} else {
2792
-			$GLOBALS['profondeur_url'] = max(
2793
-				0,
2794
-				substr_count($uri[0], '/')
2795
-				- substr_count($uri_ref, '/')
2796
-			);
2797
-		}
2798
-	}
2799
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2800
-	if (_FILE_CONNECT) {
2801
-		if (
2802
-			verifier_visiteur() == '0minirezo'
2803
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2804
-			and !isset($_COOKIE['spip_admin'])
2805
-		) {
2806
-			clear_path_cache();
2807
-		}
2808
-	}
2499
+    static $too_late = 0;
2500
+    if ($too_late++) {
2501
+        return;
2502
+    }
2503
+
2504
+    // Declaration des repertoires
2505
+
2506
+    // le nom du repertoire plugins/ activables/desactivables
2507
+    if (!defined('_DIR_PLUGINS')) {
2508
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2509
+    }
2510
+
2511
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2512
+    if (!defined('_DIR_PLUGINS_DIST')) {
2513
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2514
+    }
2515
+
2516
+    // le nom du repertoire des librairies
2517
+    if (!defined('_DIR_LIB')) {
2518
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2519
+    }
2520
+
2521
+    // répertoire des libs via Composer
2522
+    if (!defined('_DIR_VENDOR')) {
2523
+        define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
2524
+    }
2525
+
2526
+    if (!defined('_DIR_IMG')) {
2527
+        define('_DIR_IMG', $pa);
2528
+    }
2529
+    if (!defined('_DIR_LOGOS')) {
2530
+        define('_DIR_LOGOS', $pa);
2531
+    }
2532
+    if (!defined('_DIR_IMG_ICONES')) {
2533
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2534
+    }
2535
+
2536
+    if (!defined('_DIR_DUMP')) {
2537
+        define('_DIR_DUMP', $ti . 'dump/');
2538
+    }
2539
+    if (!defined('_DIR_SESSIONS')) {
2540
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2541
+    }
2542
+    if (!defined('_DIR_TRANSFERT')) {
2543
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2544
+    }
2545
+    if (!defined('_DIR_CACHE')) {
2546
+        define('_DIR_CACHE', $ti . 'cache/');
2547
+    }
2548
+    if (!defined('_DIR_CACHE_XML')) {
2549
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2550
+    }
2551
+    if (!defined('_DIR_SKELS')) {
2552
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2553
+    }
2554
+    if (!defined('_DIR_AIDE')) {
2555
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2556
+    }
2557
+    if (!defined('_DIR_TMP')) {
2558
+        define('_DIR_TMP', $ti);
2559
+    }
2560
+
2561
+    if (!defined('_DIR_VAR')) {
2562
+        define('_DIR_VAR', $ta);
2563
+    }
2564
+
2565
+    if (!defined('_DIR_ETC')) {
2566
+        define('_DIR_ETC', $pi);
2567
+    }
2568
+    if (!defined('_DIR_CONNECT')) {
2569
+        define('_DIR_CONNECT', $pi);
2570
+    }
2571
+    if (!defined('_DIR_CHMOD')) {
2572
+        define('_DIR_CHMOD', $pi);
2573
+    }
2574
+
2575
+    if (!isset($GLOBALS['test_dirs'])) {
2576
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2577
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2578
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2579
+    }
2580
+
2581
+    // Declaration des fichiers
2582
+
2583
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2584
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2585
+    }
2586
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2587
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2588
+    }
2589
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2590
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2591
+    }
2592
+    if (!defined('_CACHE_PIPELINES')) {
2593
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2594
+    }
2595
+    if (!defined('_CACHE_CHEMIN')) {
2596
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2597
+    }
2598
+
2599
+    # attention .php obligatoire pour ecrire_fichier_securise
2600
+    if (!defined('_FILE_META')) {
2601
+        define('_FILE_META', $ti . 'meta_cache.php');
2602
+    }
2603
+    if (!defined('_DIR_LOG')) {
2604
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2605
+    }
2606
+    if (!defined('_FILE_LOG')) {
2607
+        define('_FILE_LOG', 'spip');
2608
+    }
2609
+    if (!defined('_FILE_LOG_SUFFIX')) {
2610
+        define('_FILE_LOG_SUFFIX', '.log');
2611
+    }
2612
+
2613
+    // Le fichier de connexion a la base de donnees
2614
+    // tient compte des anciennes versions (inc_connect...)
2615
+    if (!defined('_FILE_CONNECT_INS')) {
2616
+        define('_FILE_CONNECT_INS', 'connect');
2617
+    }
2618
+    if (!defined('_FILE_CONNECT')) {
2619
+        define(
2620
+            '_FILE_CONNECT',
2621
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2622
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2623
+            : false))
2624
+        );
2625
+    }
2626
+
2627
+    // Le fichier de reglages des droits
2628
+    if (!defined('_FILE_CHMOD_INS')) {
2629
+        define('_FILE_CHMOD_INS', 'chmod');
2630
+    }
2631
+    if (!defined('_FILE_CHMOD')) {
2632
+        define(
2633
+            '_FILE_CHMOD',
2634
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2635
+            : false)
2636
+        );
2637
+    }
2638
+
2639
+    if (!defined('_FILE_LDAP')) {
2640
+        define('_FILE_LDAP', 'ldap.php');
2641
+    }
2642
+
2643
+    if (!defined('_FILE_TMP_SUFFIX')) {
2644
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2645
+    }
2646
+    if (!defined('_FILE_CONNECT_TMP')) {
2647
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2648
+    }
2649
+    if (!defined('_FILE_CHMOD_TMP')) {
2650
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2651
+    }
2652
+
2653
+    // Definition des droits d'acces en ecriture
2654
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2655
+        include_once _FILE_CHMOD;
2656
+    }
2657
+
2658
+    // Se mefier des fichiers mal remplis!
2659
+    if (!defined('_SPIP_CHMOD')) {
2660
+        define('_SPIP_CHMOD', 0777);
2661
+    }
2662
+
2663
+    if (!defined('_DEFAULT_CHARSET')) {
2664
+        /** Le charset par défaut lors de l'installation */
2665
+        define('_DEFAULT_CHARSET', 'utf-8');
2666
+    }
2667
+    if (!defined('_ROOT_PLUGINS')) {
2668
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2669
+    }
2670
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2671
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2672
+    }
2673
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2674
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2675
+    }
2676
+
2677
+    // La taille des Log
2678
+    if (!defined('_MAX_LOG')) {
2679
+        define('_MAX_LOG', 100);
2680
+    }
2681
+
2682
+    // Sommes-nous dans l'empire du Mal ?
2683
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2684
+    if (isset($_SERVER['SERVER_SOFTWARE']) and str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) {
2685
+        if (!defined('_OS_SERVEUR')) {
2686
+            define('_OS_SERVEUR', 'windows');
2687
+        }
2688
+        if (!defined('_SPIP_LOCK_MODE')) {
2689
+            define('_SPIP_LOCK_MODE', 1);
2690
+        } // utiliser le flock php
2691
+    } else {
2692
+        if (!defined('_OS_SERVEUR')) {
2693
+            define('_OS_SERVEUR', '');
2694
+        }
2695
+        if (!defined('_SPIP_LOCK_MODE')) {
2696
+            define('_SPIP_LOCK_MODE', 1);
2697
+        } // utiliser le flock php
2698
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2699
+    }
2700
+
2701
+    // Langue par defaut
2702
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2703
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2704
+    }
2705
+
2706
+    //
2707
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2708
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2709
+    // pour le rendre surchargeable, on va provoquer un reecriture
2710
+    // systematique du noyau ou une baisse de perfs => a etudier)
2711
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2712
+
2713
+    // charger tout de suite le path et son cache
2714
+    load_path_cache();
2715
+
2716
+    // *********** traiter les variables ************
2717
+
2718
+    //
2719
+    // Securite
2720
+    //
2721
+
2722
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2723
+    if (isset($_REQUEST['GLOBALS'])) {
2724
+        die();
2725
+    }
2726
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2727
+    spip_desinfecte($_GET);
2728
+    spip_desinfecte($_POST);
2729
+    spip_desinfecte($_COOKIE);
2730
+    spip_desinfecte($_REQUEST);
2731
+
2732
+    // appliquer le cookie_prefix
2733
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2734
+        include_spip('inc/cookie');
2735
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2736
+    }
2737
+
2738
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2739
+    if (isset($_SERVER['REQUEST_URI'])) {
2740
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2741
+    } else {
2742
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2743
+        if (
2744
+            !empty($_SERVER['QUERY_STRING'])
2745
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2746
+        ) {
2747
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2748
+        }
2749
+    }
2750
+
2751
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2752
+    if (!defined('_RENOUVELLE_ALEA')) {
2753
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2754
+    }
2755
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2756
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2757
+    }
2758
+
2759
+    // charger les meta si possible et renouveller l'alea au besoin
2760
+    // charge aussi effacer_meta et ecrire_meta
2761
+    $inc_meta = charger_fonction('meta', 'inc');
2762
+    $inc_meta();
2763
+
2764
+    // nombre de repertoires depuis la racine
2765
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2766
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2767
+    // le calcul est faux)
2768
+    if (!_DIR_RESTREINT) {
2769
+        $GLOBALS['profondeur_url'] = 1;
2770
+    } else {
2771
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2772
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
2773
+        if (
2774
+            !$uri_ref
2775
+            // si on est appele avec un autre ti, on est sans doute en mutu
2776
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2777
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2778
+            // s'en remettre a l'adresse du site. alea jacta est.
2779
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2780
+        ) {
2781
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2782
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2783
+                $uri_ref = ($uri_ref['path'] ?? '') . '/';
2784
+            } else {
2785
+                $uri_ref = '';
2786
+            }
2787
+        }
2788
+        if (!$uri or !$uri_ref) {
2789
+            $GLOBALS['profondeur_url'] = 0;
2790
+        } else {
2791
+            $GLOBALS['profondeur_url'] = max(
2792
+                0,
2793
+                substr_count($uri[0], '/')
2794
+                - substr_count($uri_ref, '/')
2795
+            );
2796
+        }
2797
+    }
2798
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2799
+    if (_FILE_CONNECT) {
2800
+        if (
2801
+            verifier_visiteur() == '0minirezo'
2802
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2803
+            and !isset($_COOKIE['spip_admin'])
2804
+        ) {
2805
+            clear_path_cache();
2806
+        }
2807
+    }
2809 2808
 }
2810 2809
 
2811 2810
 /**
@@ -2814,157 +2813,157 @@  discard block
 block discarded – undo
2814 2813
  *
2815 2814
  */
2816 2815
 function spip_initialisation_suite() {
2817
-	static $too_late = 0;
2818
-	if ($too_late++) {
2819
-		return;
2820
-	}
2821
-
2822
-	// taille mini des login
2823
-	if (!defined('_LOGIN_TROP_COURT')) {
2824
-		define('_LOGIN_TROP_COURT', 4);
2825
-	}
2826
-
2827
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2828
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2829
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2830
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2831
-
2832
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2833
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2834
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2835
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2836
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2837
-
2838
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2839
-		define('_PASS_LONGUEUR_MINI', 6);
2840
-	}
2841
-
2842
-	// largeur maximale des images dans l'administration
2843
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2844
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2845
-	}
2846
-
2847
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2848
-	if (!defined('_IMG_QUALITE')) {
2849
-		define('_IMG_QUALITE', 85);
2850
-	} # valeur par defaut
2851
-	if (!defined('_IMG_GD_QUALITE')) {
2852
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2853
-	} # surcharge pour la lib GD
2854
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2855
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2856
-	} # surcharge pour imagick en ligne de commande
2857
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2858
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2859
-		define('_IMG_IMAGICK_QUALITE', 75);
2860
-	} # surcharge pour imagick en PHP
2861
-
2862
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2863
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2864
-	} // poids en octet
2865
-
2866
-	// qq chaines standard
2867
-	if (!defined('_ACCESS_FILE_NAME')) {
2868
-		define('_ACCESS_FILE_NAME', '.htaccess');
2869
-	}
2870
-	if (!defined('_AUTH_USER_FILE')) {
2871
-		define('_AUTH_USER_FILE', '.htpasswd');
2872
-	}
2873
-	if (!defined('_SPIP_DUMP')) {
2874
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2875
-	}
2876
-	if (!defined('_CACHE_RUBRIQUES')) {
2877
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2878
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2879
-	}
2880
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2881
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2882
-		define('_CACHE_RUBRIQUES_MAX', 500);
2883
-	}
2884
-
2885
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2886
-		/**
2887
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2888
-		 * @var int Nombre de caractères */
2889
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2890
-	}
2891
-
2892
-	if (!defined('_EXTENSION_SQUELETTES')) {
2893
-		define('_EXTENSION_SQUELETTES', 'html');
2894
-	}
2895
-
2896
-	if (!defined('_DOCTYPE_ECRIRE')) {
2897
-		/** Définit le doctype de l’espace privé */
2898
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2899
-	}
2900
-	if (!defined('_DOCTYPE_AIDE')) {
2901
-		/** Définit le doctype de l’aide en ligne */
2902
-		define(
2903
-			'_DOCTYPE_AIDE',
2904
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2905
-		);
2906
-	}
2907
-
2908
-	if (!defined('_SPIP_SCRIPT')) {
2909
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2910
-		 * le script de l'espace public, alias index.php */
2911
-		define('_SPIP_SCRIPT', 'spip.php');
2912
-	}
2913
-	if (!defined('_SPIP_PAGE')) {
2914
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2915
-		define('_SPIP_PAGE', 'page');
2916
-	}
2917
-
2918
-	// le script de l'espace prive
2919
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2920
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2921
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2922
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2923
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2924
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2925
-		} else {
2926
-			define('_SPIP_ECRIRE_SCRIPT', '');
2927
-		}
2928
-	}
2929
-
2930
-
2931
-	if (!defined('_SPIP_AJAX')) {
2932
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2933
-			? 1
2934
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2935
-	}
2936
-
2937
-	// La requete est-elle en ajax ?
2938
-	if (!defined('_AJAX')) {
2939
-		define(
2940
-			'_AJAX',
2941
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2942
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2943
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2944
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2945
-			)
2946
-			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
2947
-		);
2948
-	}
2949
-
2950
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2951
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2952
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2953
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2954
-		define(
2955
-			'_IMG_GD_MAX_PIXELS',
2956
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2957
-			? $GLOBALS['meta']['max_taille_vignettes']
2958
-			: 0
2959
-		);
2960
-	}
2961
-
2962
-	// Protocoles a normaliser dans les chaines de langues
2963
-	if (!defined('_PROTOCOLES_STD')) {
2964
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2965
-	}
2966
-
2967
-	init_var_mode();
2816
+    static $too_late = 0;
2817
+    if ($too_late++) {
2818
+        return;
2819
+    }
2820
+
2821
+    // taille mini des login
2822
+    if (!defined('_LOGIN_TROP_COURT')) {
2823
+        define('_LOGIN_TROP_COURT', 4);
2824
+    }
2825
+
2826
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2827
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2828
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2829
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2830
+
2831
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2832
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2833
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2834
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2835
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2836
+
2837
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2838
+        define('_PASS_LONGUEUR_MINI', 6);
2839
+    }
2840
+
2841
+    // largeur maximale des images dans l'administration
2842
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2843
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
2844
+    }
2845
+
2846
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2847
+    if (!defined('_IMG_QUALITE')) {
2848
+        define('_IMG_QUALITE', 85);
2849
+    } # valeur par defaut
2850
+    if (!defined('_IMG_GD_QUALITE')) {
2851
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2852
+    } # surcharge pour la lib GD
2853
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2854
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2855
+    } # surcharge pour imagick en ligne de commande
2856
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2857
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2858
+        define('_IMG_IMAGICK_QUALITE', 75);
2859
+    } # surcharge pour imagick en PHP
2860
+
2861
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2862
+        define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2863
+    } // poids en octet
2864
+
2865
+    // qq chaines standard
2866
+    if (!defined('_ACCESS_FILE_NAME')) {
2867
+        define('_ACCESS_FILE_NAME', '.htaccess');
2868
+    }
2869
+    if (!defined('_AUTH_USER_FILE')) {
2870
+        define('_AUTH_USER_FILE', '.htpasswd');
2871
+    }
2872
+    if (!defined('_SPIP_DUMP')) {
2873
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2874
+    }
2875
+    if (!defined('_CACHE_RUBRIQUES')) {
2876
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2877
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2878
+    }
2879
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2880
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2881
+        define('_CACHE_RUBRIQUES_MAX', 500);
2882
+    }
2883
+
2884
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2885
+        /**
2886
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2887
+         * @var int Nombre de caractères */
2888
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2889
+    }
2890
+
2891
+    if (!defined('_EXTENSION_SQUELETTES')) {
2892
+        define('_EXTENSION_SQUELETTES', 'html');
2893
+    }
2894
+
2895
+    if (!defined('_DOCTYPE_ECRIRE')) {
2896
+        /** Définit le doctype de l’espace privé */
2897
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2898
+    }
2899
+    if (!defined('_DOCTYPE_AIDE')) {
2900
+        /** Définit le doctype de l’aide en ligne */
2901
+        define(
2902
+            '_DOCTYPE_AIDE',
2903
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2904
+        );
2905
+    }
2906
+
2907
+    if (!defined('_SPIP_SCRIPT')) {
2908
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2909
+         * le script de l'espace public, alias index.php */
2910
+        define('_SPIP_SCRIPT', 'spip.php');
2911
+    }
2912
+    if (!defined('_SPIP_PAGE')) {
2913
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2914
+        define('_SPIP_PAGE', 'page');
2915
+    }
2916
+
2917
+    // le script de l'espace prive
2918
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2919
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2920
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2921
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2922
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2923
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2924
+        } else {
2925
+            define('_SPIP_ECRIRE_SCRIPT', '');
2926
+        }
2927
+    }
2928
+
2929
+
2930
+    if (!defined('_SPIP_AJAX')) {
2931
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2932
+            ? 1
2933
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2934
+    }
2935
+
2936
+    // La requete est-elle en ajax ?
2937
+    if (!defined('_AJAX')) {
2938
+        define(
2939
+            '_AJAX',
2940
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2941
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2942
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2943
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2944
+            )
2945
+            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
2946
+        );
2947
+    }
2948
+
2949
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2950
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2951
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2952
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2953
+        define(
2954
+            '_IMG_GD_MAX_PIXELS',
2955
+            (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2956
+            ? $GLOBALS['meta']['max_taille_vignettes']
2957
+            : 0
2958
+        );
2959
+    }
2960
+
2961
+    // Protocoles a normaliser dans les chaines de langues
2962
+    if (!defined('_PROTOCOLES_STD')) {
2963
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2964
+    }
2965
+
2966
+    init_var_mode();
2968 2967
 }
2969 2968
 
2970 2969
 /**
@@ -2998,136 +2997,136 @@  discard block
 block discarded – undo
2998 2997
  * `   var_mode` (calcul ou recalcul).
2999 2998
  */
3000 2999
 function init_var_mode() {
3001
-	static $done = false;
3002
-	if (!$done) {
3003
-		if (isset($_GET['var_mode'])) {
3004
-			$var_mode = explode(',', $_GET['var_mode']);
3005
-			// tout le monde peut calcul/recalcul
3006
-			if (!defined('_VAR_MODE')) {
3007
-				if (in_array('recalcul', $var_mode)) {
3008
-					define('_VAR_MODE', 'recalcul');
3009
-				} elseif (in_array('calcul', $var_mode)) {
3010
-					define('_VAR_MODE', 'calcul');
3011
-				}
3012
-			}
3013
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3014
-			if ($var_mode) {
3015
-				include_spip('inc/autoriser');
3016
-				// autoriser preview si preview seulement, et sinon autoriser debug
3017
-				if (
3018
-					autoriser(
3019
-						($_GET['var_mode'] == 'preview')
3020
-						? 'previsualiser'
3021
-						: 'debug'
3022
-					)
3023
-				) {
3024
-					if (in_array('traduction', $var_mode)) {
3025
-						// forcer le calcul pour passer dans traduire
3026
-						if (!defined('_VAR_MODE')) {
3027
-							define('_VAR_MODE', 'calcul');
3028
-						}
3029
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3030
-						if (!defined('_VAR_NOCACHE')) {
3031
-							define('_VAR_NOCACHE', true);
3032
-						}
3033
-						$var_mode = array_diff($var_mode, ['traduction']);
3034
-					}
3035
-					if (in_array('preview', $var_mode)) {
3036
-						// basculer sur les criteres de preview dans les boucles
3037
-						if (!defined('_VAR_PREVIEW')) {
3038
-							define('_VAR_PREVIEW', true);
3039
-						}
3040
-						// forcer le calcul
3041
-						if (!defined('_VAR_MODE')) {
3042
-							define('_VAR_MODE', 'calcul');
3043
-						}
3044
-						// et ne pas enregistrer de cache
3045
-						if (!defined('_VAR_NOCACHE')) {
3046
-							define('_VAR_NOCACHE', true);
3047
-						}
3048
-						$var_mode = array_diff($var_mode, ['preview']);
3049
-					}
3050
-					if (in_array('inclure', $var_mode)) {
3051
-						// forcer le compilo et ignorer les caches existants
3052
-						if (!defined('_VAR_MODE')) {
3053
-							define('_VAR_MODE', 'calcul');
3054
-						}
3055
-						if (!defined('_VAR_INCLURE')) {
3056
-							define('_VAR_INCLURE', true);
3057
-						}
3058
-						// et ne pas enregistrer de cache
3059
-						if (!defined('_VAR_NOCACHE')) {
3060
-							define('_VAR_NOCACHE', true);
3061
-						}
3062
-						$var_mode = array_diff($var_mode, ['inclure']);
3063
-					}
3064
-					if (in_array('urls', $var_mode)) {
3065
-						// forcer le compilo et ignorer les caches existants
3066
-						if (!defined('_VAR_MODE')) {
3067
-							define('_VAR_MODE', 'calcul');
3068
-						}
3069
-						if (!defined('_VAR_URLS')) {
3070
-							define('_VAR_URLS', true);
3071
-						}
3072
-						$var_mode = array_diff($var_mode, ['urls']);
3073
-					}
3074
-					if (in_array('images', $var_mode)) {
3075
-						// forcer le compilo et ignorer les caches existants
3076
-						if (!defined('_VAR_MODE')) {
3077
-							define('_VAR_MODE', 'calcul');
3078
-						}
3079
-						// indiquer qu'on doit recalculer les images
3080
-						if (!defined('_VAR_IMAGES')) {
3081
-							define('_VAR_IMAGES', true);
3082
-						}
3083
-						$var_mode = array_diff($var_mode, ['images']);
3084
-					}
3085
-					if (in_array('debug', $var_mode)) {
3086
-						if (!defined('_VAR_MODE')) {
3087
-							define('_VAR_MODE', 'debug');
3088
-						}
3089
-						// et ne pas enregistrer de cache
3090
-						if (!defined('_VAR_NOCACHE')) {
3091
-							define('_VAR_NOCACHE', true);
3092
-						}
3093
-						$var_mode = array_diff($var_mode, ['debug']);
3094
-					}
3095
-					if (count($var_mode) and !defined('_VAR_MODE')) {
3096
-						define('_VAR_MODE', reset($var_mode));
3097
-					}
3098
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
3099
-						spip_log($GLOBALS['visiteur_session']['nom']
3100
-							. ' ' . _VAR_MODE);
3101
-					}
3102
-				} // pas autorise ?
3103
-				else {
3104
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3105
-					if (
3106
-						!$GLOBALS['visiteur_session']
3107
-						and !empty($_SERVER['HTTP_HOST'])
3108
-						and !empty($_SERVER['REQUEST_METHOD'])
3109
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3110
-					) {
3111
-						$self = self('&', true);
3112
-						if (strpos($self, 'page=login') === false) {
3113
-							include_spip('inc/headers');
3114
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3115
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3116
-						}
3117
-					}
3118
-					// sinon tant pis
3119
-				}
3120
-			}
3121
-		}
3122
-		if (!defined('_VAR_MODE')) {
3123
-			/**
3124
-			 * Indique le mode de calcul ou d'affichage de la page.
3125
-			 * @see init_var_mode()
3126
-			 */
3127
-			define('_VAR_MODE', false);
3128
-		}
3129
-		$done = true;
3130
-	}
3000
+    static $done = false;
3001
+    if (!$done) {
3002
+        if (isset($_GET['var_mode'])) {
3003
+            $var_mode = explode(',', $_GET['var_mode']);
3004
+            // tout le monde peut calcul/recalcul
3005
+            if (!defined('_VAR_MODE')) {
3006
+                if (in_array('recalcul', $var_mode)) {
3007
+                    define('_VAR_MODE', 'recalcul');
3008
+                } elseif (in_array('calcul', $var_mode)) {
3009
+                    define('_VAR_MODE', 'calcul');
3010
+                }
3011
+            }
3012
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3013
+            if ($var_mode) {
3014
+                include_spip('inc/autoriser');
3015
+                // autoriser preview si preview seulement, et sinon autoriser debug
3016
+                if (
3017
+                    autoriser(
3018
+                        ($_GET['var_mode'] == 'preview')
3019
+                        ? 'previsualiser'
3020
+                        : 'debug'
3021
+                    )
3022
+                ) {
3023
+                    if (in_array('traduction', $var_mode)) {
3024
+                        // forcer le calcul pour passer dans traduire
3025
+                        if (!defined('_VAR_MODE')) {
3026
+                            define('_VAR_MODE', 'calcul');
3027
+                        }
3028
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3029
+                        if (!defined('_VAR_NOCACHE')) {
3030
+                            define('_VAR_NOCACHE', true);
3031
+                        }
3032
+                        $var_mode = array_diff($var_mode, ['traduction']);
3033
+                    }
3034
+                    if (in_array('preview', $var_mode)) {
3035
+                        // basculer sur les criteres de preview dans les boucles
3036
+                        if (!defined('_VAR_PREVIEW')) {
3037
+                            define('_VAR_PREVIEW', true);
3038
+                        }
3039
+                        // forcer le calcul
3040
+                        if (!defined('_VAR_MODE')) {
3041
+                            define('_VAR_MODE', 'calcul');
3042
+                        }
3043
+                        // et ne pas enregistrer de cache
3044
+                        if (!defined('_VAR_NOCACHE')) {
3045
+                            define('_VAR_NOCACHE', true);
3046
+                        }
3047
+                        $var_mode = array_diff($var_mode, ['preview']);
3048
+                    }
3049
+                    if (in_array('inclure', $var_mode)) {
3050
+                        // forcer le compilo et ignorer les caches existants
3051
+                        if (!defined('_VAR_MODE')) {
3052
+                            define('_VAR_MODE', 'calcul');
3053
+                        }
3054
+                        if (!defined('_VAR_INCLURE')) {
3055
+                            define('_VAR_INCLURE', true);
3056
+                        }
3057
+                        // et ne pas enregistrer de cache
3058
+                        if (!defined('_VAR_NOCACHE')) {
3059
+                            define('_VAR_NOCACHE', true);
3060
+                        }
3061
+                        $var_mode = array_diff($var_mode, ['inclure']);
3062
+                    }
3063
+                    if (in_array('urls', $var_mode)) {
3064
+                        // forcer le compilo et ignorer les caches existants
3065
+                        if (!defined('_VAR_MODE')) {
3066
+                            define('_VAR_MODE', 'calcul');
3067
+                        }
3068
+                        if (!defined('_VAR_URLS')) {
3069
+                            define('_VAR_URLS', true);
3070
+                        }
3071
+                        $var_mode = array_diff($var_mode, ['urls']);
3072
+                    }
3073
+                    if (in_array('images', $var_mode)) {
3074
+                        // forcer le compilo et ignorer les caches existants
3075
+                        if (!defined('_VAR_MODE')) {
3076
+                            define('_VAR_MODE', 'calcul');
3077
+                        }
3078
+                        // indiquer qu'on doit recalculer les images
3079
+                        if (!defined('_VAR_IMAGES')) {
3080
+                            define('_VAR_IMAGES', true);
3081
+                        }
3082
+                        $var_mode = array_diff($var_mode, ['images']);
3083
+                    }
3084
+                    if (in_array('debug', $var_mode)) {
3085
+                        if (!defined('_VAR_MODE')) {
3086
+                            define('_VAR_MODE', 'debug');
3087
+                        }
3088
+                        // et ne pas enregistrer de cache
3089
+                        if (!defined('_VAR_NOCACHE')) {
3090
+                            define('_VAR_NOCACHE', true);
3091
+                        }
3092
+                        $var_mode = array_diff($var_mode, ['debug']);
3093
+                    }
3094
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
3095
+                        define('_VAR_MODE', reset($var_mode));
3096
+                    }
3097
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
3098
+                        spip_log($GLOBALS['visiteur_session']['nom']
3099
+                            . ' ' . _VAR_MODE);
3100
+                    }
3101
+                } // pas autorise ?
3102
+                else {
3103
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3104
+                    if (
3105
+                        !$GLOBALS['visiteur_session']
3106
+                        and !empty($_SERVER['HTTP_HOST'])
3107
+                        and !empty($_SERVER['REQUEST_METHOD'])
3108
+                        and $_SERVER['REQUEST_METHOD'] === 'GET'
3109
+                    ) {
3110
+                        $self = self('&', true);
3111
+                        if (strpos($self, 'page=login') === false) {
3112
+                            include_spip('inc/headers');
3113
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3114
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3115
+                        }
3116
+                    }
3117
+                    // sinon tant pis
3118
+                }
3119
+            }
3120
+        }
3121
+        if (!defined('_VAR_MODE')) {
3122
+            /**
3123
+             * Indique le mode de calcul ou d'affichage de la page.
3124
+             * @see init_var_mode()
3125
+             */
3126
+            define('_VAR_MODE', false);
3127
+        }
3128
+        $done = true;
3129
+    }
3131 3130
 }
3132 3131
 
3133 3132
 /**
@@ -3139,16 +3138,16 @@  discard block
 block discarded – undo
3139 3138
  * @param bool $deep = true : appliquer récursivement
3140 3139
 **/
3141 3140
 function spip_desinfecte(&$t, $deep = true) {
3142
-	foreach ($t as $key => $val) {
3143
-		if (is_string($t[$key])) {
3144
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3145
-		} // traiter aussi les "texte_plus" de article_edit
3146
-		else {
3147
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3148
-				spip_desinfecte($t[$key], $deep);
3149
-			}
3150
-		}
3151
-	}
3141
+    foreach ($t as $key => $val) {
3142
+        if (is_string($t[$key])) {
3143
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3144
+        } // traiter aussi les "texte_plus" de article_edit
3145
+        else {
3146
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3147
+                spip_desinfecte($t[$key], $deep);
3148
+            }
3149
+        }
3150
+    }
3152 3151
 }
3153 3152
 
3154 3153
 /**
@@ -3161,64 +3160,64 @@  discard block
 block discarded – undo
3161 3160
  * @return string|0|false
3162 3161
 **/
3163 3162
 function verifier_visiteur() {
3164
-	@spip_initialisation_core(
3165
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3166
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3167
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3168
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3169
-	);
3170
-
3171
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3172
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3173
-	// Attention on separe bien session_nom et nom, pour eviter
3174
-	// les melanges entre donnees SQL et variables plus aleatoires
3175
-	$variables_session = ['session_nom', 'session_email'];
3176
-	foreach ($variables_session as $var) {
3177
-		if (_request($var) !== null) {
3178
-			$init = true;
3179
-			break;
3180
-		}
3181
-	}
3182
-	if (isset($init)) {
3183
-		#@spip_initialisation_suite();
3184
-		$session = charger_fonction('session', 'inc');
3185
-		$session();
3186
-		include_spip('inc/texte');
3187
-		foreach ($variables_session as $var) {
3188
-			if (($a = _request($var)) !== null) {
3189
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3190
-			}
3191
-		}
3192
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3193
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3194
-		}
3195
-		$session($GLOBALS['visiteur_session']);
3196
-
3197
-		return 0;
3198
-	}
3199
-
3200
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3201
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3202
-		$session = charger_fonction('session', 'inc');
3203
-		if ($session()) {
3204
-			return $GLOBALS['visiteur_session']['statut'];
3205
-		}
3206
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3207
-			include_spip('inc/auth');
3208
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3209
-		}
3210
-		if ($h) {
3211
-			$GLOBALS['visiteur_session'] = $h;
3212
-
3213
-			return $GLOBALS['visiteur_session']['statut'];
3214
-		}
3215
-	}
3216
-
3217
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3218
-	include_spip('inc/lang');
3219
-	utiliser_langue_visiteur();
3220
-
3221
-	return false;
3163
+    @spip_initialisation_core(
3164
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3165
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3166
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3167
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3168
+    );
3169
+
3170
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3171
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3172
+    // Attention on separe bien session_nom et nom, pour eviter
3173
+    // les melanges entre donnees SQL et variables plus aleatoires
3174
+    $variables_session = ['session_nom', 'session_email'];
3175
+    foreach ($variables_session as $var) {
3176
+        if (_request($var) !== null) {
3177
+            $init = true;
3178
+            break;
3179
+        }
3180
+    }
3181
+    if (isset($init)) {
3182
+        #@spip_initialisation_suite();
3183
+        $session = charger_fonction('session', 'inc');
3184
+        $session();
3185
+        include_spip('inc/texte');
3186
+        foreach ($variables_session as $var) {
3187
+            if (($a = _request($var)) !== null) {
3188
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3189
+            }
3190
+        }
3191
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3192
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3193
+        }
3194
+        $session($GLOBALS['visiteur_session']);
3195
+
3196
+        return 0;
3197
+    }
3198
+
3199
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3200
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3201
+        $session = charger_fonction('session', 'inc');
3202
+        if ($session()) {
3203
+            return $GLOBALS['visiteur_session']['statut'];
3204
+        }
3205
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3206
+            include_spip('inc/auth');
3207
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3208
+        }
3209
+        if ($h) {
3210
+            $GLOBALS['visiteur_session'] = $h;
3211
+
3212
+            return $GLOBALS['visiteur_session']['statut'];
3213
+        }
3214
+    }
3215
+
3216
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3217
+    include_spip('inc/lang');
3218
+    utiliser_langue_visiteur();
3219
+
3220
+    return false;
3222 3221
 }
3223 3222
 
3224 3223
 
@@ -3241,21 +3240,21 @@  discard block
 block discarded – undo
3241 3240
  *     - string Langue utilisée.
3242 3241
  **/
3243 3242
 function lang_select($lang = null) {
3244
-	static $pile_langues = [];
3245
-	if (!function_exists('changer_langue')) {
3246
-		include_spip('inc/lang');
3247
-	}
3248
-	if ($lang === null) {
3249
-		$lang = array_pop($pile_langues);
3250
-	} else {
3251
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3252
-	}
3253
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3254
-		return $lang;
3255
-	}
3256
-	changer_langue($lang);
3243
+    static $pile_langues = [];
3244
+    if (!function_exists('changer_langue')) {
3245
+        include_spip('inc/lang');
3246
+    }
3247
+    if ($lang === null) {
3248
+        $lang = array_pop($pile_langues);
3249
+    } else {
3250
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3251
+    }
3252
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3253
+        return $lang;
3254
+    }
3255
+    changer_langue($lang);
3257 3256
 
3258
-	return $lang;
3257
+    return $lang;
3259 3258
 }
3260 3259
 
3261 3260
 /**
@@ -3272,20 +3271,20 @@  discard block
 block discarded – undo
3272 3271
  *     Identifiant de la session
3273 3272
  **/
3274 3273
 function spip_session($force = false) {
3275
-	static $session;
3276
-	if ($force or !isset($session)) {
3277
-		$s = pipeline(
3278
-			'definir_session',
3279
-			$GLOBALS['visiteur_session']
3280
-				? serialize($GLOBALS['visiteur_session'])
3281
-				. '_' . @$_COOKIE['spip_session']
3282
-				: ''
3283
-		);
3284
-		$session = $s ? substr(md5($s), 0, 8) : '';
3285
-	}
3274
+    static $session;
3275
+    if ($force or !isset($session)) {
3276
+        $s = pipeline(
3277
+            'definir_session',
3278
+            $GLOBALS['visiteur_session']
3279
+                ? serialize($GLOBALS['visiteur_session'])
3280
+                . '_' . @$_COOKIE['spip_session']
3281
+                : ''
3282
+        );
3283
+        $session = $s ? substr(md5($s), 0, 8) : '';
3284
+    }
3286 3285
 
3287
-	#spip_log('session: '.$session);
3288
-	return $session;
3286
+    #spip_log('session: '.$session);
3287
+    return $session;
3289 3288
 }
3290 3289
 
3291 3290
 
@@ -3304,9 +3303,9 @@  discard block
 block discarded – undo
3304 3303
  *    Lien sur une icone d'aide
3305 3304
  **/
3306 3305
 function aider($aide = '', $distante = false) {
3307
-	$aider = charger_fonction('aide', 'inc', true);
3306
+    $aider = charger_fonction('aide', 'inc', true);
3308 3307
 
3309
-	return $aider ? $aider($aide, '', [], $distante) : '';
3308
+    return $aider ? $aider($aide, '', [], $distante) : '';
3310 3309
 }
3311 3310
 
3312 3311
 /**
@@ -3316,35 +3315,35 @@  discard block
 block discarded – undo
3316 3315
  */
3317 3316
 function exec_info_dist() {
3318 3317
 
3319
-	include_spip('inc/autoriser');
3320
-	if (autoriser('phpinfos')) {
3321
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3322
-		$cookies_backup = [];
3323
-		$server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
3324
-		$env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
3325
-		$mask = '******************************';
3326
-		foreach ($cookies_masques as $k) {
3327
-			if (!empty($_COOKIE[$k])) {
3328
-				$cookies_backup[$k] = $_COOKIE[$k];
3329
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3330
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3331
-				$_COOKIE[$k] = $mask;
3332
-			}
3333
-		}
3334
-		phpinfo();
3335
-		foreach ($cookies_backup as $k => $v) {
3336
-			$_COOKIE[$k] = $v;
3337
-		}
3338
-		foreach ($server_backup as $k => $v) {
3339
-			$_SERVER[$k] = $v;
3340
-		}
3341
-		foreach ($env_backup as $k => $v) {
3342
-			$_ENV[$k] = $v;
3343
-		}
3344
-	} else {
3345
-		include_spip('inc/filtres');
3346
-		sinon_interdire_acces();
3347
-	}
3318
+    include_spip('inc/autoriser');
3319
+    if (autoriser('phpinfos')) {
3320
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3321
+        $cookies_backup = [];
3322
+        $server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
3323
+        $env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
3324
+        $mask = '******************************';
3325
+        foreach ($cookies_masques as $k) {
3326
+            if (!empty($_COOKIE[$k])) {
3327
+                $cookies_backup[$k] = $_COOKIE[$k];
3328
+                $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
3329
+                $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
3330
+                $_COOKIE[$k] = $mask;
3331
+            }
3332
+        }
3333
+        phpinfo();
3334
+        foreach ($cookies_backup as $k => $v) {
3335
+            $_COOKIE[$k] = $v;
3336
+        }
3337
+        foreach ($server_backup as $k => $v) {
3338
+            $_SERVER[$k] = $v;
3339
+        }
3340
+        foreach ($env_backup as $k => $v) {
3341
+            $_ENV[$k] = $v;
3342
+        }
3343
+    } else {
3344
+        include_spip('inc/filtres');
3345
+        sinon_interdire_acces();
3346
+    }
3348 3347
 }
3349 3348
 
3350 3349
 /**
@@ -3364,13 +3363,13 @@  discard block
 block discarded – undo
3364 3363
  *     - string si $message à false.
3365 3364
  **/
3366 3365
 function erreur_squelette($message = '', $lieu = '') {
3367
-	$debusquer = charger_fonction('debusquer', 'public');
3368
-	if (is_array($lieu)) {
3369
-		include_spip('public/compiler');
3370
-		$lieu = reconstruire_contexte_compil($lieu);
3371
-	}
3366
+    $debusquer = charger_fonction('debusquer', 'public');
3367
+    if (is_array($lieu)) {
3368
+        include_spip('public/compiler');
3369
+        $lieu = reconstruire_contexte_compil($lieu);
3370
+    }
3372 3371
 
3373
-	return $debusquer($message, $lieu);
3372
+    return $debusquer($message, $lieu);
3374 3373
 }
3375 3374
 
3376 3375
 /**
@@ -3407,108 +3406,108 @@  discard block
 block discarded – undo
3407 3406
  *     - ou tableau d'information sur le squelette.
3408 3407
  */
3409 3408
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
3410
-	if (!function_exists('evaluer_fond')) {
3411
-		include_spip('public/assembler');
3412
-	}
3413
-	// assurer la compat avec l'ancienne syntaxe
3414
-	// (trim etait le 3eme argument, par defaut a true)
3415
-	if (!is_array($options)) {
3416
-		$options = ['trim' => $options];
3417
-	}
3418
-	if (!isset($options['trim'])) {
3419
-		$options['trim'] = true;
3420
-	}
3421
-
3422
-	if (isset($contexte['connect'])) {
3423
-		$connect = $contexte['connect'];
3424
-		unset($contexte['connect']);
3425
-	}
3426
-
3427
-	$texte = '';
3428
-	$pages = [];
3429
-	$lang_select = '';
3430
-	if (!isset($options['etoile']) or !$options['etoile']) {
3431
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3432
-		if (!isset($contexte['lang'])) {
3433
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3434
-		}
3435
-
3436
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3437
-			$lang_select = lang_select($contexte['lang']);
3438
-		}
3439
-	}
3440
-
3441
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3442
-		$GLOBALS['_INC_PUBLIC'] = 0;
3443
-	}
3444
-
3445
-	$GLOBALS['_INC_PUBLIC']++;
3446
-
3447
-	// fix #4235
3448
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3449
-
3450
-
3451
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3452
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3453
-
3454
-		$page = evaluer_fond($f, $contexte, $connect);
3455
-		if ($page === '') {
3456
-			$c = $options['compil'] ?? '';
3457
-			$a = ['fichier' => $f];
3458
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3459
-			erreur_squelette($erreur, $c);
3460
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3461
-			$page = ['texte' => '', 'erreur' => $erreur];
3462
-		}
3463
-
3464
-		$page = pipeline('recuperer_fond', [
3465
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3466
-			'data' => $page
3467
-		]);
3468
-		if (isset($options['ajax']) and $options['ajax']) {
3469
-			if (!function_exists('encoder_contexte_ajax')) {
3470
-				include_spip('inc/filtres');
3471
-			}
3472
-			$page['texte'] = encoder_contexte_ajax(
3473
-				array_merge(
3474
-					$contexte,
3475
-					['fond' => $f],
3476
-					($connect ? ['connect' => $connect] : [])
3477
-				),
3478
-				'',
3479
-				$page['texte'],
3480
-				$options['ajax']
3481
-			);
3482
-		}
3483
-
3484
-		if (isset($options['raw']) and $options['raw']) {
3485
-			$pages[] = $page;
3486
-		} else {
3487
-			$texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3488
-		}
3489
-
3490
-		// contamination de la session appelante, pour les inclusions statiques
3491
-		if (isset($page['invalideurs']['session'])) {
3492
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3493
-		}
3494
-	}
3495
-
3496
-	// restaurer le sessionnement du contexte appelant,
3497
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3498
-	if (isset($cache_utilise_session_appelant)) {
3499
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3500
-	}
3501
-
3502
-	$GLOBALS['_INC_PUBLIC']--;
3503
-
3504
-	if ($lang_select) {
3505
-		lang_select();
3506
-	}
3507
-	if (isset($options['raw']) and $options['raw']) {
3508
-		return is_array($fond) ? $pages : reset($pages);
3509
-	} else {
3510
-		return $options['trim'] ? ltrim($texte) : $texte;
3511
-	}
3409
+    if (!function_exists('evaluer_fond')) {
3410
+        include_spip('public/assembler');
3411
+    }
3412
+    // assurer la compat avec l'ancienne syntaxe
3413
+    // (trim etait le 3eme argument, par defaut a true)
3414
+    if (!is_array($options)) {
3415
+        $options = ['trim' => $options];
3416
+    }
3417
+    if (!isset($options['trim'])) {
3418
+        $options['trim'] = true;
3419
+    }
3420
+
3421
+    if (isset($contexte['connect'])) {
3422
+        $connect = $contexte['connect'];
3423
+        unset($contexte['connect']);
3424
+    }
3425
+
3426
+    $texte = '';
3427
+    $pages = [];
3428
+    $lang_select = '';
3429
+    if (!isset($options['etoile']) or !$options['etoile']) {
3430
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3431
+        if (!isset($contexte['lang'])) {
3432
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3433
+        }
3434
+
3435
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3436
+            $lang_select = lang_select($contexte['lang']);
3437
+        }
3438
+    }
3439
+
3440
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3441
+        $GLOBALS['_INC_PUBLIC'] = 0;
3442
+    }
3443
+
3444
+    $GLOBALS['_INC_PUBLIC']++;
3445
+
3446
+    // fix #4235
3447
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3448
+
3449
+
3450
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3451
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3452
+
3453
+        $page = evaluer_fond($f, $contexte, $connect);
3454
+        if ($page === '') {
3455
+            $c = $options['compil'] ?? '';
3456
+            $a = ['fichier' => $f];
3457
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3458
+            erreur_squelette($erreur, $c);
3459
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3460
+            $page = ['texte' => '', 'erreur' => $erreur];
3461
+        }
3462
+
3463
+        $page = pipeline('recuperer_fond', [
3464
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3465
+            'data' => $page
3466
+        ]);
3467
+        if (isset($options['ajax']) and $options['ajax']) {
3468
+            if (!function_exists('encoder_contexte_ajax')) {
3469
+                include_spip('inc/filtres');
3470
+            }
3471
+            $page['texte'] = encoder_contexte_ajax(
3472
+                array_merge(
3473
+                    $contexte,
3474
+                    ['fond' => $f],
3475
+                    ($connect ? ['connect' => $connect] : [])
3476
+                ),
3477
+                '',
3478
+                $page['texte'],
3479
+                $options['ajax']
3480
+            );
3481
+        }
3482
+
3483
+        if (isset($options['raw']) and $options['raw']) {
3484
+            $pages[] = $page;
3485
+        } else {
3486
+            $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3487
+        }
3488
+
3489
+        // contamination de la session appelante, pour les inclusions statiques
3490
+        if (isset($page['invalideurs']['session'])) {
3491
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3492
+        }
3493
+    }
3494
+
3495
+    // restaurer le sessionnement du contexte appelant,
3496
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3497
+    if (isset($cache_utilise_session_appelant)) {
3498
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3499
+    }
3500
+
3501
+    $GLOBALS['_INC_PUBLIC']--;
3502
+
3503
+    if ($lang_select) {
3504
+        lang_select();
3505
+    }
3506
+    if (isset($options['raw']) and $options['raw']) {
3507
+        return is_array($fond) ? $pages : reset($pages);
3508
+    } else {
3509
+        return $options['trim'] ? ltrim($texte) : $texte;
3510
+    }
3512 3511
 }
3513 3512
 
3514 3513
 /**
@@ -3518,7 +3517,7 @@  discard block
 block discarded – undo
3518 3517
  * @return string
3519 3518
  */
3520 3519
 function trouve_modele($nom) {
3521
-	return trouver_fond($nom, 'modeles/');
3520
+    return trouver_fond($nom, 'modeles/');
3522 3521
 }
3523 3522
 
3524 3523
 /**
@@ -3534,21 +3533,21 @@  discard block
 block discarded – undo
3534 3533
  * @return array|string
3535 3534
  */
3536 3535
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3537
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3538
-	if (!$pathinfo) {
3539
-		return $f;
3540
-	}
3541
-	// renvoyer un tableau detaille si $pathinfo==true
3542
-	$p = pathinfo($f);
3543
-	if (!isset($p['extension']) or !$p['extension']) {
3544
-		$p['extension'] = _EXTENSION_SQUELETTES;
3545
-	}
3546
-	if (!isset($p['extension']) or !$p['filename']) {
3547
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3548
-	}
3549
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3536
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3537
+    if (!$pathinfo) {
3538
+        return $f;
3539
+    }
3540
+    // renvoyer un tableau detaille si $pathinfo==true
3541
+    $p = pathinfo($f);
3542
+    if (!isset($p['extension']) or !$p['extension']) {
3543
+        $p['extension'] = _EXTENSION_SQUELETTES;
3544
+    }
3545
+    if (!isset($p['extension']) or !$p['filename']) {
3546
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3547
+    }
3548
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3550 3549
 
3551
-	return $p;
3550
+    return $p;
3552 3551
 }
3553 3552
 
3554 3553
 /**
@@ -3568,21 +3567,21 @@  discard block
 block discarded – undo
3568 3567
  *     Nom de l'exec, sinon chaîne vide.
3569 3568
  **/
3570 3569
 function tester_url_ecrire($nom) {
3571
-	static $exec = [];
3572
-	if (isset($exec[$nom])) {
3573
-		return $exec[$nom];
3574
-	}
3575
-	// tester si c'est une page en squelette
3576
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3577
-		return $exec[$nom] = 'fond';
3578
-	} // echafaudage d'un fond !
3579
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3580
-		return $exec[$nom] = 'fond';
3581
-	}
3582
-	// attention, il ne faut pas inclure l'exec ici
3583
-	// car sinon #URL_ECRIRE provoque des inclusions
3584
-	// et des define intrusifs potentiels
3585
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3570
+    static $exec = [];
3571
+    if (isset($exec[$nom])) {
3572
+        return $exec[$nom];
3573
+    }
3574
+    // tester si c'est une page en squelette
3575
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3576
+        return $exec[$nom] = 'fond';
3577
+    } // echafaudage d'un fond !
3578
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3579
+        return $exec[$nom] = 'fond';
3580
+    }
3581
+    // attention, il ne faut pas inclure l'exec ici
3582
+    // car sinon #URL_ECRIRE provoque des inclusions
3583
+    // et des define intrusifs potentiels
3584
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3586 3585
 }
3587 3586
 
3588 3587
 /**
@@ -3592,8 +3591,8 @@  discard block
 block discarded – undo
3592 3591
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3593 3592
  **/
3594 3593
 function html5_permis() {
3595
-	return (!defined('_VERSION_HTML')
3596
-		or _VERSION_HTML !== 'html4');
3594
+    return (!defined('_VERSION_HTML')
3595
+        or _VERSION_HTML !== 'html4');
3597 3596
 }
3598 3597
 
3599 3598
 /**
@@ -3603,30 +3602,30 @@  discard block
 block discarded – undo
3603 3602
  * @return array
3604 3603
  */
3605 3604
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3606
-	$formats = null;
3607
-	if (!is_null($gd)) {
3608
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3609
-		if (isset($GLOBALS['meta'][$config])) {
3610
-			$formats = $GLOBALS['meta'][$config];
3611
-			$formats = explode(',', $formats);
3612
-			$formats = array_filter($formats);
3613
-			$formats = array_map('trim', $formats);
3614
-		}
3615
-	}
3616
-	if (is_null($formats)) {
3617
-		include_spip('inc/filtres_images_lib_mini');
3618
-		$formats = _image_extensions_acceptees_en_entree();
3619
-	}
3620
-
3621
-	if ($svg_allowed) {
3622
-		if (!in_array('svg', $formats)) {
3623
-			$formats[] = 'svg';
3624
-		}
3625
-	}
3626
-	else {
3627
-		$formats = array_diff($formats, ['svg']);
3628
-	}
3629
-	return $formats;
3605
+    $formats = null;
3606
+    if (!is_null($gd)) {
3607
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3608
+        if (isset($GLOBALS['meta'][$config])) {
3609
+            $formats = $GLOBALS['meta'][$config];
3610
+            $formats = explode(',', $formats);
3611
+            $formats = array_filter($formats);
3612
+            $formats = array_map('trim', $formats);
3613
+        }
3614
+    }
3615
+    if (is_null($formats)) {
3616
+        include_spip('inc/filtres_images_lib_mini');
3617
+        $formats = _image_extensions_acceptees_en_entree();
3618
+    }
3619
+
3620
+    if ($svg_allowed) {
3621
+        if (!in_array('svg', $formats)) {
3622
+            $formats[] = 'svg';
3623
+        }
3624
+    }
3625
+    else {
3626
+        $formats = array_diff($formats, ['svg']);
3627
+    }
3628
+    return $formats;
3630 3629
 }
3631 3630
 
3632 3631
 /**
@@ -3635,20 +3634,20 @@  discard block
 block discarded – undo
3635 3634
  * @return array|bool
3636 3635
  */
3637 3636
 function spip_getimagesize($fichier) {
3638
-	if (!$imagesize = @getimagesize($fichier)) {
3639
-		include_spip('inc/svg');
3640
-		if ($attrs = svg_lire_attributs($fichier)) {
3641
-			[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3642
-			$imagesize = [
3643
-				$width,
3644
-				$height,
3645
-				IMAGETYPE_SVG,
3646
-				"width=\"{$width}\" height=\"{$height}\"",
3647
-				'mime' => 'image/svg+xml'
3648
-			];
3649
-		}
3650
-	}
3651
-	return $imagesize;
3637
+    if (!$imagesize = @getimagesize($fichier)) {
3638
+        include_spip('inc/svg');
3639
+        if ($attrs = svg_lire_attributs($fichier)) {
3640
+            [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3641
+            $imagesize = [
3642
+                $width,
3643
+                $height,
3644
+                IMAGETYPE_SVG,
3645
+                "width=\"{$width}\" height=\"{$height}\"",
3646
+                'mime' => 'image/svg+xml'
3647
+            ];
3648
+        }
3649
+    }
3650
+    return $imagesize;
3652 3651
 }
3653 3652
 
3654 3653
 /**
@@ -3662,19 +3661,19 @@  discard block
 block discarded – undo
3662 3661
  * @param string $statut
3663 3662
  */
3664 3663
 function avertir_auteurs($nom, $message, $statut = '') {
3665
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3666
-	if (
3667
-		!$alertes
3668
-		or !is_array($alertes = unserialize($alertes))
3669
-	) {
3670
-		$alertes = [];
3671
-	}
3664
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3665
+    if (
3666
+        !$alertes
3667
+        or !is_array($alertes = unserialize($alertes))
3668
+    ) {
3669
+        $alertes = [];
3670
+    }
3672 3671
 
3673
-	if (!isset($alertes[$statut])) {
3674
-		$alertes[$statut] = [];
3675
-	}
3676
-	$alertes[$statut][$nom] = $message;
3677
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3672
+    if (!isset($alertes[$statut])) {
3673
+        $alertes[$statut] = [];
3674
+    }
3675
+    $alertes[$statut][$nom] = $message;
3676
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3678 3677
 }
3679 3678
 
3680 3679
 /**
@@ -3688,10 +3687,10 @@  discard block
 block discarded – undo
3688 3687
  * @return string|string[]
3689 3688
  */
3690 3689
 function spip_sanitize_classname($classes) {
3691
-	if (is_array($classes)) {
3692
-		return array_map('spip_sanitize_classname', $classes);
3693
-	}
3694
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3690
+    if (is_array($classes)) {
3691
+        return array_map('spip_sanitize_classname', $classes);
3692
+    }
3693
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3695 3694
 }
3696 3695
 
3697 3696
 
@@ -3716,32 +3715,32 @@  discard block
 block discarded – undo
3716 3715
  *    Avec operateur : bool.
3717 3716
  **/
3718 3717
 function spip_version_compare($v1, $v2, $op = null) {
3719
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3720
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3721
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3722
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3723
-
3724
-	$v1 = explode('.', $v1);
3725
-	$v2 = explode('.', $v2);
3726
-	// $v1 est toujours une version, donc sans etoile
3727
-	while (count($v1) < count($v2)) {
3728
-		$v1[] = '0';
3729
-	}
3730
-
3731
-	// $v2 peut etre une borne, donc accepte l'etoile
3732
-	$etoile = false;
3733
-	foreach ($v1 as $k => $v) {
3734
-		if (!isset($v2[$k])) {
3735
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3736
-		} else {
3737
-			if ($v2[$k] == '*') {
3738
-				$etoile = true;
3739
-				$v2[$k] = $v;
3740
-			}
3741
-		}
3742
-	}
3743
-	$v1 = implode('.', $v1);
3744
-	$v2 = implode('.', $v2);
3745
-
3746
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3718
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3719
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3720
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3721
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3722
+
3723
+    $v1 = explode('.', $v1);
3724
+    $v2 = explode('.', $v2);
3725
+    // $v1 est toujours une version, donc sans etoile
3726
+    while (count($v1) < count($v2)) {
3727
+        $v1[] = '0';
3728
+    }
3729
+
3730
+    // $v2 peut etre une borne, donc accepte l'etoile
3731
+    $etoile = false;
3732
+    foreach ($v1 as $k => $v) {
3733
+        if (!isset($v2[$k])) {
3734
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3735
+        } else {
3736
+            if ($v2[$k] == '*') {
3737
+                $etoile = true;
3738
+                $v2[$k] = $v;
3739
+            }
3740
+        }
3741
+    }
3742
+    $v1 = implode('.', $v1);
3743
+    $v2 = implode('.', $v2);
3744
+
3745
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3747 3746
 }
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.
ecrire/inc/meta.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			renouvelle_alea();
66 66
 			$new = false;
67 67
 		} else {
68
-			spip_log("impossible d'ecrire dans " . $cache);
68
+			spip_log("impossible d'ecrire dans ".$cache);
69 69
 		}
70 70
 	}
71 71
 	// et refaire le cache si on a du lire en base
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	if (!isset($touch[$table])) {
167 167
 		touch_meta($antidate, $table);
168 168
 	}
169
-	sql_delete('spip_' . $table, "nom='$nom'", '', 'continue');
169
+	sql_delete('spip_'.$table, "nom='$nom'", '', 'continue');
170 170
 	unset($GLOBALS[$table][$nom]);
171 171
 	if (!isset($touch[$table])) {
172 172
 		touch_meta($antidate, $table);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		return;
198 198
 	}
199 199
 	include_spip('base/abstract_sql');
200
-	$res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue');
200
+	$res = sql_select('*', 'spip_'.$table, 'nom='.sql_quote($nom), '', '', '', '', '', 'continue');
201 201
 	// table pas encore installee, travailler en php seulement
202 202
 	if (!$res) {
203 203
 		$GLOBALS[$table][$nom] = $valeur;
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 		$r['impt'] = sql_quote($importable, '', 'text');
232 232
 	}
233 233
 	if ($row) {
234
-		sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom));
234
+		sql_update('spip_'.$table, $r, 'nom='.sql_quote($nom));
235 235
 	} else {
236
-		sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')');
236
+		sql_insert('spip_'.$table, '('.join(',', array_keys($r)).')', '('.join(',', array_values($r)).')');
237 237
 	}
238 238
 	if (!isset($touch[$table])) {
239 239
 		touch_meta($antidate, $table);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  *     Nom du fichier cache
251 251
  **/
252 252
 function cache_meta($table = 'meta') {
253
-	return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
253
+	return ($table == 'meta') ? _FILE_META : (_DIR_CACHE.$table.'.php');
254 254
 }
255 255
 
256 256
 /**
Please login to merge, or discard this patch.
Indentation   +197 added lines, -197 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
 // Les parametres generaux du site sont dans une table SQL;
@@ -27,51 +27,51 @@  discard block
 block discarded – undo
27 27
 define('_META_CACHE_TIME', 1 << 24);
28 28
 
29 29
 function inc_meta_dist($table = 'meta') {
30
-	$new = null;
31
-	// Lire les meta, en cache si present, valide et lisible
32
-	// en cas d'install ne pas faire confiance au meta_cache eventuel
33
-	$cache = cache_meta($table);
30
+    $new = null;
31
+    // Lire les meta, en cache si present, valide et lisible
32
+    // en cas d'install ne pas faire confiance au meta_cache eventuel
33
+    $cache = cache_meta($table);
34 34
 
35
-	if (
36
-		(!$exec = _request('exec') or !autoriser_sans_cookie($exec))
37
-		and $new = jeune_fichier($cache, _META_CACHE_TIME)
38
-		and lire_fichier_securise($cache, $meta)
39
-		and $meta = @unserialize($meta)
40
-	) {
41
-		$GLOBALS[$table] = $meta;
42
-	}
35
+    if (
36
+        (!$exec = _request('exec') or !autoriser_sans_cookie($exec))
37
+        and $new = jeune_fichier($cache, _META_CACHE_TIME)
38
+        and lire_fichier_securise($cache, $meta)
39
+        and $meta = @unserialize($meta)
40
+    ) {
41
+        $GLOBALS[$table] = $meta;
42
+    }
43 43
 
44
-	if (
45
-		isset($GLOBALS[$table]['touch'])
46
-		and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME)
47
-	) {
48
-		$GLOBALS[$table] = [];
49
-	}
50
-	// sinon lire en base
51
-	if (!$GLOBALS[$table]) {
52
-		$new = !lire_metas($table);
53
-	}
44
+    if (
45
+        isset($GLOBALS[$table]['touch'])
46
+        and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME)
47
+    ) {
48
+        $GLOBALS[$table] = [];
49
+    }
50
+    // sinon lire en base
51
+    if (!$GLOBALS[$table]) {
52
+        $new = !lire_metas($table);
53
+    }
54 54
 
55
-	// renouveller l'alea general si trop vieux ou sur demande explicite
56
-	if (
57
-		(test_espace_prive() || isset($_GET['renouvelle_alea']))
58
-		and $GLOBALS[$table]
59
-		and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0))
60
-	) {
61
-		// si on n'a pas l'acces en ecriture sur le cache,
62
-		// ne pas renouveller l'alea sinon le cache devient faux
63
-		if (supprimer_fichier($cache)) {
64
-			include_spip('inc/acces');
65
-			renouvelle_alea();
66
-			$new = false;
67
-		} else {
68
-			spip_log("impossible d'ecrire dans " . $cache);
69
-		}
70
-	}
71
-	// et refaire le cache si on a du lire en base
72
-	if (!$new) {
73
-		touch_meta(false, $table);
74
-	}
55
+    // renouveller l'alea general si trop vieux ou sur demande explicite
56
+    if (
57
+        (test_espace_prive() || isset($_GET['renouvelle_alea']))
58
+        and $GLOBALS[$table]
59
+        and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0))
60
+    ) {
61
+        // si on n'a pas l'acces en ecriture sur le cache,
62
+        // ne pas renouveller l'alea sinon le cache devient faux
63
+        if (supprimer_fichier($cache)) {
64
+            include_spip('inc/acces');
65
+            renouvelle_alea();
66
+            $new = false;
67
+        } else {
68
+            spip_log("impossible d'ecrire dans " . $cache);
69
+        }
70
+    }
71
+    // et refaire le cache si on a du lire en base
72
+    if (!$new) {
73
+        touch_meta(false, $table);
74
+    }
75 75
 }
76 76
 
77 77
 // fonctions aussi appelees a l'install ==> spip_query en premiere requete
@@ -79,39 +79,39 @@  discard block
 block discarded – undo
79 79
 
80 80
 function lire_metas($table = 'meta') {
81 81
 
82
-	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
83
-		include_spip('base/abstract_sql');
84
-		$GLOBALS[$table] = [];
85
-		while ($row = sql_fetch($result)) {
86
-			$GLOBALS[$table][$row['nom']] = $row['valeur'];
87
-		}
88
-		sql_free($result);
82
+    if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
83
+        include_spip('base/abstract_sql');
84
+        $GLOBALS[$table] = [];
85
+        while ($row = sql_fetch($result)) {
86
+            $GLOBALS[$table][$row['nom']] = $row['valeur'];
87
+        }
88
+        sql_free($result);
89 89
 
90
-		if (
91
-			!isset($GLOBALS[$table]['charset'])
92
-			or !$GLOBALS[$table]['charset']
93
-			or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
94
-		) {
95
-			ecrire_meta('charset', _DEFAULT_CHARSET, null, $table);
96
-		}
90
+        if (
91
+            !isset($GLOBALS[$table]['charset'])
92
+            or !$GLOBALS[$table]['charset']
93
+            or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
94
+        ) {
95
+            ecrire_meta('charset', _DEFAULT_CHARSET, null, $table);
96
+        }
97 97
 
98
-		// noter cette table de configuration dans les meta de SPIP
99
-		if ($table !== 'meta') {
100
-			$liste = [];
101
-			if (isset($GLOBALS['meta']['tables_config'])) {
102
-				$liste = unserialize($GLOBALS['meta']['tables_config']);
103
-			}
104
-			if (!$liste) {
105
-				$liste = [];
106
-			}
107
-			if (!in_array($table, $liste)) {
108
-				$liste[] = $table;
109
-				ecrire_meta('tables_config', serialize($liste));
110
-			}
111
-		}
112
-	}
98
+        // noter cette table de configuration dans les meta de SPIP
99
+        if ($table !== 'meta') {
100
+            $liste = [];
101
+            if (isset($GLOBALS['meta']['tables_config'])) {
102
+                $liste = unserialize($GLOBALS['meta']['tables_config']);
103
+            }
104
+            if (!$liste) {
105
+                $liste = [];
106
+            }
107
+            if (!in_array($table, $liste)) {
108
+                $liste[] = $table;
109
+                ecrire_meta('tables_config', serialize($liste));
110
+            }
111
+        }
112
+    }
113 113
 
114
-	return $GLOBALS[$table] ?? null;
114
+    return $GLOBALS[$table] ?? null;
115 115
 }
116 116
 
117 117
 
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
  *      Table SQL d'enregistrement des meta.
126 126
  **/
127 127
 function touch_meta($antidate = false, $table = 'meta') {
128
-	$file = cache_meta($table);
129
-	if (!$antidate or !@touch($file, $antidate)) {
130
-		$r = $GLOBALS[$table] ?? [];
131
-		if ($table == 'meta') {
132
-			unset($r['alea_ephemere']);
133
-			unset($r['alea_ephemere_ancien']);
134
-			// le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
135
-			// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
136
-			// meme si son squelette est en cache
137
-			//unset($r['secret_du_site']);
138
-			if ($antidate) {
139
-				$r['touch'] = $antidate;
140
-			}
141
-		}
142
-		ecrire_fichier_securise($file, serialize($r));
143
-	}
128
+    $file = cache_meta($table);
129
+    if (!$antidate or !@touch($file, $antidate)) {
130
+        $r = $GLOBALS[$table] ?? [];
131
+        if ($table == 'meta') {
132
+            unset($r['alea_ephemere']);
133
+            unset($r['alea_ephemere_ancien']);
134
+            // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
135
+            // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
136
+            // meme si son squelette est en cache
137
+            //unset($r['secret_du_site']);
138
+            if ($antidate) {
139
+                $r['touch'] = $antidate;
140
+            }
141
+        }
142
+        ecrire_fichier_securise($file, serialize($r));
143
+    }
144 144
 }
145 145
 
146 146
 /**
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
  *     Table SQL d'enregistrement de la meta.
157 157
  **/
158 158
 function effacer_meta($nom, $table = 'meta') {
159
-	// section critique sur le cache:
160
-	// l'invalider avant et apres la MAJ de la BD
161
-	// c'est un peu moins bien qu'un vrai verrou mais ca suffira
162
-	// et utiliser une statique pour eviter des acces disques a repetition
163
-	static $touch = [];
164
-	$antidate = time() - (_META_CACHE_TIME << 4);
165
-	if (!isset($touch[$table])) {
166
-		touch_meta($antidate, $table);
167
-	}
168
-	sql_delete('spip_' . $table, "nom='$nom'", '', 'continue');
169
-	unset($GLOBALS[$table][$nom]);
170
-	if (!isset($touch[$table])) {
171
-		touch_meta($antidate, $table);
172
-		$touch[$table] = false;
173
-	}
159
+    // section critique sur le cache:
160
+    // l'invalider avant et apres la MAJ de la BD
161
+    // c'est un peu moins bien qu'un vrai verrou mais ca suffira
162
+    // et utiliser une statique pour eviter des acces disques a repetition
163
+    static $touch = [];
164
+    $antidate = time() - (_META_CACHE_TIME << 4);
165
+    if (!isset($touch[$table])) {
166
+        touch_meta($antidate, $table);
167
+    }
168
+    sql_delete('spip_' . $table, "nom='$nom'", '', 'continue');
169
+    unset($GLOBALS[$table][$nom]);
170
+    if (!isset($touch[$table])) {
171
+        touch_meta($antidate, $table);
172
+        $touch[$table] = false;
173
+    }
174 174
 }
175 175
 
176 176
 /**
@@ -191,53 +191,53 @@  discard block
 block discarded – undo
191 191
  **/
192 192
 function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') {
193 193
 
194
-	static $touch = [];
195
-	if (!$nom) {
196
-		return;
197
-	}
198
-	include_spip('base/abstract_sql');
199
-	$res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue');
200
-	// table pas encore installee, travailler en php seulement
201
-	if (!$res) {
202
-		$GLOBALS[$table][$nom] = $valeur;
194
+    static $touch = [];
195
+    if (!$nom) {
196
+        return;
197
+    }
198
+    include_spip('base/abstract_sql');
199
+    $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue');
200
+    // table pas encore installee, travailler en php seulement
201
+    if (!$res) {
202
+        $GLOBALS[$table][$nom] = $valeur;
203 203
 
204
-		return;
205
-	}
206
-	$row = sql_fetch($res);
207
-	sql_free($res);
204
+        return;
205
+    }
206
+    $row = sql_fetch($res);
207
+    sql_free($res);
208 208
 
209
-	// ne pas invalider le cache si affectation a l'identique
210
-	// (tant pis si impt aurait du changer)
211
-	if (
212
-		$row and $valeur == $row['valeur']
213
-		and isset($GLOBALS[$table][$nom])
214
-		and $GLOBALS[$table][$nom] == $valeur
215
-	) {
216
-		return;
217
-	}
209
+    // ne pas invalider le cache si affectation a l'identique
210
+    // (tant pis si impt aurait du changer)
211
+    if (
212
+        $row and $valeur == $row['valeur']
213
+        and isset($GLOBALS[$table][$nom])
214
+        and $GLOBALS[$table][$nom] == $valeur
215
+    ) {
216
+        return;
217
+    }
218 218
 
219
-	$GLOBALS[$table][$nom] = $valeur;
220
-	// cf effacer pour comprendre le double touch
221
-	$antidate = time() - (_META_CACHE_TIME << 1);
222
-	if (!isset($touch[$table])) {
223
-		touch_meta($antidate, $table);
224
-	}
225
-	$r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')];
226
-	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
227
-	// ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot
228
-	// de lecture des descriptions des tables
229
-	if ($importable and isset($row['impt'])) {
230
-		$r['impt'] = sql_quote($importable, '', 'text');
231
-	}
232
-	if ($row) {
233
-		sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom));
234
-	} else {
235
-		sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')');
236
-	}
237
-	if (!isset($touch[$table])) {
238
-		touch_meta($antidate, $table);
239
-		$touch[$table] = false;
240
-	}
219
+    $GLOBALS[$table][$nom] = $valeur;
220
+    // cf effacer pour comprendre le double touch
221
+    $antidate = time() - (_META_CACHE_TIME << 1);
222
+    if (!isset($touch[$table])) {
223
+        touch_meta($antidate, $table);
224
+    }
225
+    $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')];
226
+    // Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
227
+    // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot
228
+    // de lecture des descriptions des tables
229
+    if ($importable and isset($row['impt'])) {
230
+        $r['impt'] = sql_quote($importable, '', 'text');
231
+    }
232
+    if ($row) {
233
+        sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom));
234
+    } else {
235
+        sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')');
236
+    }
237
+    if (!isset($touch[$table])) {
238
+        touch_meta($antidate, $table);
239
+        $touch[$table] = false;
240
+    }
241 241
 }
242 242
 
243 243
 /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
  *     Nom du fichier cache
250 250
  **/
251 251
 function cache_meta($table = 'meta') {
252
-	return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
252
+    return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
253 253
 }
254 254
 
255 255
 /**
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
  * @param string $table
259 259
  */
260 260
 function installer_table_meta($table) {
261
-	$trouver_table = charger_fonction('trouver_table', 'base');
262
-	if (!$trouver_table("spip_$table")) {
263
-		include_spip('base/auxiliaires');
264
-		include_spip('base/create');
265
-		creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
266
-		$trouver_table('');
267
-	}
268
-	lire_metas($table);
261
+    $trouver_table = charger_fonction('trouver_table', 'base');
262
+    if (!$trouver_table("spip_$table")) {
263
+        include_spip('base/auxiliaires');
264
+        include_spip('base/create');
265
+        creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
266
+        $trouver_table('');
267
+    }
268
+    lire_metas($table);
269 269
 }
270 270
 
271 271
 /**
@@ -277,47 +277,47 @@  discard block
 block discarded – undo
277 277
  * @param bool $force
278 278
  */
279 279
 function supprimer_table_meta($table, $force = false) {
280
-	if ($table !== 'meta') {
281
-		// Vérifier le contenu restant de la table
282
-		$nb_variables = sql_countsel("spip_$table");
280
+    if ($table !== 'meta') {
281
+        // Vérifier le contenu restant de la table
282
+        $nb_variables = sql_countsel("spip_$table");
283 283
 
284
-		// Supprimer si :
285
-		// - la table est vide
286
-		// - ou limitée à la variable charset
287
-		// - ou qu'on force la suppression
288
-		if (
289
-			$force
290
-			or !$nb_variables
291
-			or (
292
-				($nb_variables == 1)
293
-				and isset($GLOBALS[$table]['charset'])
294
-			)
295
-		) {
296
-			// Supprimer la table des globaleset de la base
297
-			unset($GLOBALS[$table]);
298
-			sql_drop_table("spip_$table");
299
-			// Supprimer le fichier cache
300
-			include_spip('inc/flock');
301
-			$cache = cache_meta($table);
302
-			supprimer_fichier($cache);
284
+        // Supprimer si :
285
+        // - la table est vide
286
+        // - ou limitée à la variable charset
287
+        // - ou qu'on force la suppression
288
+        if (
289
+            $force
290
+            or !$nb_variables
291
+            or (
292
+                ($nb_variables == 1)
293
+                and isset($GLOBALS[$table]['charset'])
294
+            )
295
+        ) {
296
+            // Supprimer la table des globaleset de la base
297
+            unset($GLOBALS[$table]);
298
+            sql_drop_table("spip_$table");
299
+            // Supprimer le fichier cache
300
+            include_spip('inc/flock');
301
+            $cache = cache_meta($table);
302
+            supprimer_fichier($cache);
303 303
 
304
-			// vider le cache des tables
305
-			$trouver_table = charger_fonction('trouver_table', 'base');
306
-			$trouver_table('');
304
+            // vider le cache des tables
305
+            $trouver_table = charger_fonction('trouver_table', 'base');
306
+            $trouver_table('');
307 307
 
308
-			// Supprimer la table de la liste des tables de configuration autres que spip_meta
309
-			if (isset($GLOBALS['meta']['tables_config'])) {
310
-				$liste = unserialize($GLOBALS['meta']['tables_config']);
311
-				$cle = array_search($table, $liste);
312
-				if ($cle !== false) {
313
-					unset($liste[$cle]);
314
-					if ($liste) {
315
-						ecrire_meta('tables_config', serialize($liste));
316
-					} else {
317
-						effacer_meta('tables_config');
318
-					}
319
-				}
320
-			}
321
-		}
322
-	}
308
+            // Supprimer la table de la liste des tables de configuration autres que spip_meta
309
+            if (isset($GLOBALS['meta']['tables_config'])) {
310
+                $liste = unserialize($GLOBALS['meta']['tables_config']);
311
+                $cle = array_search($table, $liste);
312
+                if ($cle !== false) {
313
+                    unset($liste[$cle]);
314
+                    if ($liste) {
315
+                        ecrire_meta('tables_config', serialize($liste));
316
+                    } else {
317
+                        effacer_meta('tables_config');
318
+                    }
319
+                }
320
+            }
321
+        }
322
+    }
323 323
 }
Please login to merge, or discard this patch.
ecrire/balise/url_.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76 76
 	if ($s = trouver_nom_serveur_distant($p)) {
77 77
 		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
78
+		if (function_exists($f = 'generer_generer_url_'.$s)) {
79 79
 			return $f($type, $_id, $s);
80 80
 		}
81 81
 		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		# exception des urls de documents sur un serveur distant...
86 86
 		if ($type == 'document') {
87 87
 			return
88
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
89
-				"quete_meta('dir_img', $s) . \n\t" .
88
+				"quete_meta('adresse_site', $s) . '/' .\n\t".
89
+				"quete_meta('dir_img', $s) . \n\t".
90 90
 				"quete_fichier($_id,$s)";
91 91
 		}
92 92
 		$s = ", '', '', $s, quete_meta('type_urls', $s)";
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
  */
231 231
 function balise_URL_SITE_SPIP_dist($p) {
232 232
 	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
-	$p->code = 'spip_htmlspecialchars(' . $p->code . ')';
233
+	$p->code = 'spip_htmlspecialchars('.$p->code.')';
234 234
 	$p->interdire_scripts = false;
235 235
 
236 236
 	return $p;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	if ($s = trouver_nom_serveur_distant($p)) {
272 272
 		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
273 273
 		// elle devra aussi traiter le cas derogatoire type=page
274
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
274
+		if (function_exists($f = 'generer_generer_url_'.$s)) {
275 275
 			if ($args and $args !== "''") {
276 276
 				$code .= ", $args";
277 277
 			}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			$p->code = $code;
280 280
 			return $p;
281 281
 		}
282
-		$s = 'connect=' . addslashes($s);
282
+		$s = 'connect='.addslashes($s);
283 283
 		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284 284
 	}
285 285
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$code = "generer_url_public($code, $args$noentities)";
295 295
 	}
296 296
 	$p->code = $code;
297
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
297
+	spip_log("Calcul url page : connect vaut $s ca donne :".$p->code." args $args", _LOG_INFO);
298 298
 
299 299
 	#$p->interdire_scripts = true;
300 300
 	return $p;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			$fonc .= ",$args$noentities";
339 339
 		}
340 340
 	}
341
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
341
+	$p->code = 'generer_url_ecrire('.$fonc.')';
342 342
 	$p->interdire_scripts = false;
343 343
 
344 344
 	return $p;
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
 
374 374
 	$args = interprete_argument_balise(2, $p);
375 375
 	if ($args != "''" && $args !== null) {
376
-		$p->code .= ',' . $args;
376
+		$p->code .= ','.$args;
377 377
 	}
378 378
 	$redirect = interprete_argument_balise(3, $p);
379 379
 	if ($redirect != "''" && $redirect !== null) {
380 380
 		if ($args == "''" || $args === null) {
381 381
 			$p->code .= ",''";
382 382
 		}
383
-		$p->code .= ',' . $redirect;
383
+		$p->code .= ','.$redirect;
384 384
 	}
385 385
 
386
-	$p->code = 'generer_action_auteur(' . $p->code . ')';
386
+	$p->code = 'generer_action_auteur('.$p->code.')';
387 387
 	$p->interdire_scripts = false;
388 388
 
389 389
 	return $p;
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  **/
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
  *     Code compilé
38 38
  **/
39 39
 function generer_generer_url($type, $p) {
40
-	$_id = interprete_argument_balise(1, $p);
40
+    $_id = interprete_argument_balise(1, $p);
41 41
 
42
-	if (!$_id) {
43
-		$primary = id_table_objet($type);
44
-		$_id = champ_sql($primary, $p);
45
-	}
42
+    if (!$_id) {
43
+        $primary = id_table_objet($type);
44
+        $_id = champ_sql($primary, $p);
45
+    }
46 46
 
47
-	return generer_generer_url_arg($type, $p, $_id);
47
+    return generer_generer_url_arg($type, $p, $_id);
48 48
 }
49 49
 
50 50
 /**
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
  *     Code compilé
74 74
  **/
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76
-	if ($s = trouver_nom_serveur_distant($p)) {
77
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
79
-			return $f($type, $_id, $s);
80
-		}
81
-		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
-			return null;
83
-		}
84
-		$s = _q($s);
85
-		# exception des urls de documents sur un serveur distant...
86
-		if ($type == 'document') {
87
-			return
88
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
89
-				"quete_meta('dir_img', $s) . \n\t" .
90
-				"quete_fichier($_id,$s)";
91
-		}
92
-		$s = ", '', '', $s, quete_meta('type_urls', $s)";
93
-	} else {
94
-		$s = ", '', '', true";
95
-	}
96
-
97
-	return "urlencode_1738(generer_objet_url($_id, '$type'$s))";
76
+    if ($s = trouver_nom_serveur_distant($p)) {
77
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
79
+            return $f($type, $_id, $s);
80
+        }
81
+        if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
+            return null;
83
+        }
84
+        $s = _q($s);
85
+        # exception des urls de documents sur un serveur distant...
86
+        if ($type == 'document') {
87
+            return
88
+                "quete_meta('adresse_site', $s) . '/' .\n\t" .
89
+                "quete_meta('dir_img', $s) . \n\t" .
90
+                "quete_fichier($_id,$s)";
91
+        }
92
+        $s = ", '', '', $s, quete_meta('type_urls', $s)";
93
+    } else {
94
+        $s = ", '', '', true";
95
+    }
96
+
97
+    return "urlencode_1738(generer_objet_url($_id, '$type'$s))";
98 98
 }
99 99
 
100 100
 
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function balise_URL__dist($p) {
121 121
 
122
-	$nom = $p->nom_champ;
123
-	if ($nom === 'URL_') {
124
-		$msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
-		erreur_squelette($msg, $p);
126
-		$p->interdire_scripts = false;
127
-
128
-		return $p;
129
-	} elseif ($f = charger_fonction($nom, 'balise', true)) {
130
-		return $f($p);
131
-	} else {
132
-		$nom = strtolower($nom);
133
-		$code = generer_generer_url(substr($nom, 4), $p);
134
-		$code = champ_sql($nom, $p, $code);
135
-		$p->code = $code;
136
-		if (!$p->etoile) {
137
-			$p->code = "vider_url($code)";
138
-		}
139
-		$p->interdire_scripts = false;
140
-
141
-		return $p;
142
-	}
122
+    $nom = $p->nom_champ;
123
+    if ($nom === 'URL_') {
124
+        $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
+        erreur_squelette($msg, $p);
126
+        $p->interdire_scripts = false;
127
+
128
+        return $p;
129
+    } elseif ($f = charger_fonction($nom, 'balise', true)) {
130
+        return $f($p);
131
+    } else {
132
+        $nom = strtolower($nom);
133
+        $code = generer_generer_url(substr($nom, 4), $p);
134
+        $code = champ_sql($nom, $p, $code);
135
+        $p->code = $code;
136
+        if (!$p->etoile) {
137
+            $p->code = "vider_url($code)";
138
+        }
139
+        $p->interdire_scripts = false;
140
+
141
+        return $p;
142
+    }
143 143
 }
144 144
 
145 145
 /**
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function balise_URL_ARTICLE_dist($p) {
165 165
 
166
-	// Cas particulier des boucles (SYNDIC_ARTICLES)
167
-	if ($p->type_requete == 'syndic_articles') {
168
-		$code = champ_sql('url', $p);
169
-	} else {
170
-		$code = generer_generer_url('article', $p);
171
-	}
166
+    // Cas particulier des boucles (SYNDIC_ARTICLES)
167
+    if ($p->type_requete == 'syndic_articles') {
168
+        $code = champ_sql('url', $p);
169
+    } else {
170
+        $code = generer_generer_url('article', $p);
171
+    }
172 172
 
173
-	$p->code = $code;
174
-	if (!$p->etoile) {
175
-		$p->code = "vider_url($code)";
176
-	}
177
-	$p->interdire_scripts = false;
173
+    $p->code = $code;
174
+    if (!$p->etoile) {
175
+        $p->code = "vider_url($code)";
176
+    }
177
+    $p->interdire_scripts = false;
178 178
 
179
-	return $p;
179
+    return $p;
180 180
 }
181 181
 
182 182
 /**
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
  *     Pile complétée par le code à générer
197 197
  */
198 198
 function balise_URL_SITE_dist($p) {
199
-	$code = champ_sql('url_site', $p, '');
200
-	if (!$code) {
201
-		$code = generer_generer_url('site', $p);
202
-		if ($code === null) {
203
-			return null;
204
-		}
205
-	} else {
206
-		if (!$p->etoile) {
207
-			$code = "calculer_url($code,'','url', \$connect)";
208
-		}
209
-	}
210
-	$p->code = $code;
211
-	$p->interdire_scripts = false;
212
-
213
-	return $p;
199
+    $code = champ_sql('url_site', $p, '');
200
+    if (!$code) {
201
+        $code = generer_generer_url('site', $p);
202
+        if ($code === null) {
203
+            return null;
204
+        }
205
+    } else {
206
+        if (!$p->etoile) {
207
+            $code = "calculer_url($code,'','url', \$connect)";
208
+        }
209
+    }
210
+    $p->code = $code;
211
+    $p->interdire_scripts = false;
212
+
213
+    return $p;
214 214
 }
215 215
 
216 216
 // Autres balises URL_*, qui ne concernent pas une table
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
  *     Pile complétée par le code à générer
230 230
  */
231 231
 function balise_URL_SITE_SPIP_dist($p) {
232
-	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
-	$p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
-	$p->interdire_scripts = false;
232
+    $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
+    $p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
+    $p->interdire_scripts = false;
235 235
 
236
-	return $p;
236
+    return $p;
237 237
 }
238 238
 
239 239
 
@@ -262,42 +262,42 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function balise_URL_PAGE_dist($p) {
264 264
 
265
-	$code = interprete_argument_balise(1, $p);
266
-	$args = interprete_argument_balise(2, $p);
267
-	if ($args == null) {
268
-		$args = "''";
269
-	}
270
-
271
-	if ($s = trouver_nom_serveur_distant($p)) {
272
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
-		// elle devra aussi traiter le cas derogatoire type=page
274
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
275
-			if ($args and $args !== "''") {
276
-				$code .= ", $args";
277
-			}
278
-			$code = $f('page', $code, $s);
279
-			$p->code = $code;
280
-			return $p;
281
-		}
282
-		$s = 'connect=' . addslashes($s);
283
-		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
-	}
285
-
286
-	if (!$code) {
287
-		$noentities = $p->etoile ? "'&'" : '';
288
-		$code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
-	} else {
290
-		if (!$args) {
291
-			$args = "''";
292
-		}
293
-		$noentities = $p->etoile ? ', true' : '';
294
-		$code = "generer_url_public($code, $args$noentities)";
295
-	}
296
-	$p->code = $code;
297
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
-
299
-	#$p->interdire_scripts = true;
300
-	return $p;
265
+    $code = interprete_argument_balise(1, $p);
266
+    $args = interprete_argument_balise(2, $p);
267
+    if ($args == null) {
268
+        $args = "''";
269
+    }
270
+
271
+    if ($s = trouver_nom_serveur_distant($p)) {
272
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
+        // elle devra aussi traiter le cas derogatoire type=page
274
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
275
+            if ($args and $args !== "''") {
276
+                $code .= ", $args";
277
+            }
278
+            $code = $f('page', $code, $s);
279
+            $p->code = $code;
280
+            return $p;
281
+        }
282
+        $s = 'connect=' . addslashes($s);
283
+        $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
+    }
285
+
286
+    if (!$code) {
287
+        $noentities = $p->etoile ? "'&'" : '';
288
+        $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
+    } else {
290
+        if (!$args) {
291
+            $args = "''";
292
+        }
293
+        $noentities = $p->etoile ? ', true' : '';
294
+        $code = "generer_url_public($code, $args$noentities)";
295
+    }
296
+    $p->code = $code;
297
+    spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
+
299
+    #$p->interdire_scripts = true;
300
+    return $p;
301 301
 }
302 302
 
303 303
 
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function balise_URL_ECRIRE_dist($p) {
326 326
 
327
-	$code = interprete_argument_balise(1, $p);
328
-	if (!$code) {
329
-		$fonc = "''";
330
-	} else {
331
-		$fonc = $code;
332
-		$args = interprete_argument_balise(2, $p);
333
-		if ($args === null) {
334
-			$args = "''";
335
-		}
336
-		$noentities = $p->etoile ? ', true' : '';
337
-		if (($args != "''") or $noentities) {
338
-			$fonc .= ",$args$noentities";
339
-		}
340
-	}
341
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
342
-	$p->interdire_scripts = false;
343
-
344
-	return $p;
327
+    $code = interprete_argument_balise(1, $p);
328
+    if (!$code) {
329
+        $fonc = "''";
330
+    } else {
331
+        $fonc = $code;
332
+        $args = interprete_argument_balise(2, $p);
333
+        if ($args === null) {
334
+            $args = "''";
335
+        }
336
+        $noentities = $p->etoile ? ', true' : '';
337
+        if (($args != "''") or $noentities) {
338
+            $fonc .= ",$args$noentities";
339
+        }
340
+    }
341
+    $p->code = 'generer_url_ecrire(' . $fonc . ')';
342
+    $p->interdire_scripts = false;
343
+
344
+    return $p;
345 345
 }
346 346
 
347 347
 
@@ -367,24 +367,24 @@  discard block
 block discarded – undo
367 367
  *     Pile complétée par le code à générer
368 368
  */
369 369
 function balise_URL_ACTION_AUTEUR_dist($p) {
370
-	$p->descr['session'] = true;
371
-
372
-	$p->code = interprete_argument_balise(1, $p);
373
-
374
-	$args = interprete_argument_balise(2, $p);
375
-	if ($args != "''" && $args !== null) {
376
-		$p->code .= ',' . $args;
377
-	}
378
-	$redirect = interprete_argument_balise(3, $p);
379
-	if ($redirect != "''" && $redirect !== null) {
380
-		if ($args == "''" || $args === null) {
381
-			$p->code .= ",''";
382
-		}
383
-		$p->code .= ',' . $redirect;
384
-	}
385
-
386
-	$p->code = 'generer_action_auteur(' . $p->code . ')';
387
-	$p->interdire_scripts = false;
388
-
389
-	return $p;
370
+    $p->descr['session'] = true;
371
+
372
+    $p->code = interprete_argument_balise(1, $p);
373
+
374
+    $args = interprete_argument_balise(2, $p);
375
+    if ($args != "''" && $args !== null) {
376
+        $p->code .= ',' . $args;
377
+    }
378
+    $redirect = interprete_argument_balise(3, $p);
379
+    if ($redirect != "''" && $redirect !== null) {
380
+        if ($args == "''" || $args === null) {
381
+            $p->code .= ",''";
382
+        }
383
+        $p->code .= ',' . $redirect;
384
+    }
385
+
386
+    $p->code = 'generer_action_auteur(' . $p->code . ')';
387
+    $p->interdire_scripts = false;
388
+
389
+    return $p;
390 390
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_ecrire_auteur.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('base/abstract_sql');
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *     Pile complétée du code compilé
42 42
  **/
43 43
 function balise_FORMULAIRE_ECRIRE_AUTEUR($p) {
44
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']);
44
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']);
45 45
 }
46 46
 
47 47
 /**
@@ -59,44 +59,44 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon (erreur ou non affichage).
60 60
  */
61 61
 function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) {
62
-	include_spip('inc/filtres');
63
-	// Pas d'id_auteur ni d'id_article ? Erreur de contexte
64
-	$id = intval($args[1]);
65
-	if (!$args[0] and !$id) {
66
-		$msg = [
67
-			'zbug_champ_hors_motif',
68
-			[
69
-				'champ' => 'FORMULAIRE_ECRIRE_AUTEUR',
70
-				'motif' => 'AUTEURS/ARTICLES'
71
-			]
72
-		];
62
+    include_spip('inc/filtres');
63
+    // Pas d'id_auteur ni d'id_article ? Erreur de contexte
64
+    $id = intval($args[1]);
65
+    if (!$args[0] and !$id) {
66
+        $msg = [
67
+            'zbug_champ_hors_motif',
68
+            [
69
+                'champ' => 'FORMULAIRE_ECRIRE_AUTEUR',
70
+                'motif' => 'AUTEURS/ARTICLES'
71
+            ]
72
+        ];
73 73
 
74
-		erreur_squelette($msg, $context_compil);
74
+        erreur_squelette($msg, $context_compil);
75 75
 
76
-		return '';
77
-	}
78
-	// Si on est dans un contexte article,
79
-	// sortir tous les mails des auteurs de l'article
80
-	if (!$args[0] and $id) {
81
-		$r = '';
82
-		$s = sql_allfetsel(
83
-			'email',
84
-			'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')',
85
-			"A.email != '' AND L.id_objet=$id"
86
-		);
87
-		foreach ($s as $row) {
88
-			if (email_valide($row['email'])) {
89
-				$r .= ', ' . $row['email'];
90
-			}
91
-		}
92
-		$args[2] = substr($r, 2);
93
-	}
76
+        return '';
77
+    }
78
+    // Si on est dans un contexte article,
79
+    // sortir tous les mails des auteurs de l'article
80
+    if (!$args[0] and $id) {
81
+        $r = '';
82
+        $s = sql_allfetsel(
83
+            'email',
84
+            'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')',
85
+            "A.email != '' AND L.id_objet=$id"
86
+        );
87
+        foreach ($s as $row) {
88
+            if (email_valide($row['email'])) {
89
+                $r .= ', ' . $row['email'];
90
+            }
91
+        }
92
+        $args[2] = substr($r, 2);
93
+    }
94 94
 
95
-	// On ne peut pas ecrire a un auteur dont le mail n'est pas valide
96
-	if (!$args[2] or !email_valide($args[2])) {
97
-		return '';
98
-	}
95
+    // On ne peut pas ecrire a un auteur dont le mail n'est pas valide
96
+    if (!$args[2] or !email_valide($args[2])) {
97
+        return '';
98
+    }
99 99
 
100
-	// OK
101
-	return $args;
100
+    // OK
101
+    return $args;
102 102
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 		);
87 87
 		foreach ($s as $row) {
88 88
 			if (email_valide($row['email'])) {
89
-				$r .= ', ' . $row['email'];
89
+				$r .= ', '.$row['email'];
90 90
 			}
91 91
 		}
92 92
 		$args[2] = substr($r, 2);
Please login to merge, or discard this patch.