Completed
Push — master ( 6a6422...ff2ac0 )
by cam
01:15
created
ecrire/inc/iconifier.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/actions');
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  *     - ou tableau d'information sur le squelette.
37 37
  */
38 38
 function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) {
39
-	// compat avec anciens appels
40
-	$objet = objet_type($objet);
39
+    // compat avec anciens appels
40
+    $objet = objet_type($objet);
41 41
 
42
-	return recuperer_fond('prive/objets/editer/logo',
43
-		array('objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif));
42
+    return recuperer_fond('prive/objets/editer/logo',
43
+        array('objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif));
44 44
 }
Please login to merge, or discard this patch.
ecrire/inc/lang_liste.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	'cpf_dom' => "Kreyòl",
52 52
 	'cpf_hat' => "Kreyòl (Peyi Dayiti)",
53 53
 	'cs' => "čeština",
54
-	'cy' => "Cymraeg",  # welsh, gallois
54
+	'cy' => "Cymraeg", # welsh, gallois
55 55
 	'da' => "dansk",
56 56
 	'de' => "Deutsch",
57 57
 	'dz' => "Bhutani",
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	'hi' => "हिंदी",
93 93
 	'hr' => "hrvatski",
94 94
 	'hu' => "magyar",
95
-	'hy' => "Հայերեն",// Arménien
95
+	'hy' => "Հայերեն", // Arménien
96 96
 	'ia' => "Interlingua",
97 97
 	'id' => "Indonesia",
98 98
 	'ie' => "Interlingue",
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	'ka' => "ქართული",
107 107
 	'kk' => "қазақ тілі", // Kazakh
108 108
 	'kl' => "kalaallisut",
109
-	'km' => "ភាសាខ្មែរ",// Khmer
109
+	'km' => "ភាសាខ្មែរ", // Khmer
110 110
 	'kn' => "Kannada",
111 111
 	'ko' => "한국어",
112 112
 	'kok' => "कोंकणी",
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	'sh_latn' => 'srpskohrvastski',
177 177
 	'sh_cyrl' => 'Српскохрватски',
178 178
 	'si' => "Sinhalese",
179
-	'sk' => "slovenčina",  // (Slovakia)
180
-	'sl' => "slovenščina",  // (Slovenia)
179
+	'sk' => "slovenčina", // (Slovakia)
180
+	'sl' => "slovenščina", // (Slovenia)
181 181
 	'sm' => "Samoan",
182 182
 	'sn' => "Shona",
183 183
 	'so' => "Somali",
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -19,206 +19,206 @@
 block discarded – undo
19 19
 */
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 $GLOBALS['codes_langues'] = array(
26
-	'aa' => "Afar",
27
-	'ab' => "Abkhazian",
28
-	'af' => "Afrikaans",
29
-	'am' => "Amharic",
30
-	'an' => "Aragonés",
31
-	'ar' => "عربي",
32
-	'as' => "Assamese",
33
-	'ast' => "asturianu",
34
-	'ay' => "Aymara",
35
-	'az' => "Azərbaycan dili",
36
-	'ba' => "Bashkir",
37
-	'be' => "Беларуская",
38
-	'ber_tam' => "Tamazigh",
39
-	'ber_tam_tfng' => "Tamazigh tifinagh",
40
-	'bg' => "български",
41
-	'bh' => "Bihari",
42
-	'bi' => "Bislama",
43
-	'bm' => "Bambara",
44
-	'bn' => "Bengali; Bangla",
45
-	'bo' => "Tibetan",
46
-	'br' => "brezhoneg",
47
-	'bs' => "bosanski",
48
-	'ca' => "català",
49
-	'co' => "corsu",
50
-	'cpf' => "Kréol réyoné",
51
-	'cpf_dom' => "Kreyòl",
52
-	'cpf_hat' => "Kreyòl (Peyi Dayiti)",
53
-	'cs' => "čeština",
54
-	'cy' => "Cymraeg",  # welsh, gallois
55
-	'da' => "dansk",
56
-	'de' => "Deutsch",
57
-	'dz' => "Bhutani",
58
-	'el' => "ελληνικά",
59
-	'en' => "English",
60
-	'en_hx' => "H4ck3R",
61
-	'en_sm' => "Smurf",
62
-	'eo' => "Esperanto",
63
-	'es' => "Español",
64
-	'es_co' => "Colombiano",
65
-	'es_mx_pop' => "Mexicano a lo güey",
66
-	'et' => "eesti",
67
-	'eu' => "euskara",
68
-	'fa' => "فارسى",
69
-	'ff' => "Fulah", // peul
70
-	'fi' => "suomi",
71
-	'fj' => "Fiji",
72
-	'fo' => "føroyskt",
73
-	'fon' => "fongbè",
74
-	'fr' => "français",
75
-	'fr_fem' => "français féminin",
76
-	'fr_sc' => "schtroumpf",
77
-	'fr_lpc' => "langue parlée complétée",
78
-	'fr_lsf' => "langue des signes française",
79
-	'fr_spl' => "français simplifié",
80
-	'fr_tu' => "français copain",
81
-	'fy' => "Frisian",
82
-	'ga' => "Irish",
83
-	'gd' => "Scots Gaelic",
84
-	'gl' => "galego",
85
-	'gn' => "Guarani",
86
-	'grc' => "Ἀρχαία Ἑλληνική", // grec ancien
87
-	'gu' => "Gujarati",
88
-	'ha' => "Hausa",
89
-	'hac' => "ک-هۆرامی", //"Kurdish-Horami"
90
-	'hbo' => "עברית־התנך", // hebreu classique ou biblique
91
-	'haz' => "هزاره گی",
92
-	'he' => "עברית",
93
-	'hi' => "हिंदी",
94
-	'hr' => "hrvatski",
95
-	'hu' => "magyar",
96
-	'hy' => "Հայերեն",// Arménien
97
-	'ia' => "Interlingua",
98
-	'id' => "Indonesia",
99
-	'ie' => "Interlingue",
100
-	'ik' => "Inupiak",
101
-	'is' => "íslenska",
102
-	'it' => "italiano",
103
-	'it_fem' => "italiana",
104
-	'iu' => "Inuktitut",
105
-	'ja' => "日本語",
106
-	'jv' => "Javanese",
107
-	'ka' => "ქართული",
108
-	'kk' => "қазақ тілі", // Kazakh
109
-	'kl' => "kalaallisut",
110
-	'km' => "ភាសាខ្មែរ",// Khmer
111
-	'kn' => "Kannada",
112
-	'ko' => "한국어",
113
-	'kok' => "कोंकणी",
114
-	'ks' => "Kashmiri",
115
-	'ku' => "کوردی",
116
-	'ky' => "Kirghiz",
117
-	'la' => "lingua latina",
118
-	'lb' => "Lëtzebuergesch",
119
-	'ln' => "Lingala",
120
-	'lo' => "ພາສາລາວ", # lao
121
-	'lt' => "lietuvių",
122
-	'lu' => "luba-katanga",
123
-	'lv' => "latviešu",
124
-	'man' => "mandingue", # a traduire en mandingue
125
-	'mfv' => "manjak", # ISO-639-3
126
-	'mg' => "Malagasy",
127
-	'mi' => "Maori",
128
-	'mk' => "македонски јазик",
129
-	'ml' => "Malayalam",
130
-	'mn' => "Монгол хэл",
131
-	'mo' => "Moldavian",
132
-	'mos' => "Moré",
133
-	'mr' => "मराठी",
134
-	'ms' => "Bahasa Malaysia",
135
-	'mt' => "Maltese",
136
-	'my' => "Burmese",
137
-	'na' => "Nauru",
138
-	'nap' => "napulitano",
139
-	'ne' => "Nepali",
140
-	'nqo' => "N'ko", // www.manden.org
141
-	'nl' => "Nederlands",
142
-	'no' => "norsk",
143
-	'nb' => "norsk bokmål",
144
-	'nn' => "norsk nynorsk",
145
-	'oc' => "òc",
146
-	'oc_lnc' => "òc lengadocian",
147
-	'oc_ni' => "òc niçard",
148
-	'oc_ni_la' => "òc niçard (larg)",
149
-	'oc_ni_mis' => "òc nissart (mistralenc)",
150
-	'oc_prv' => "òc provençau",
151
-	'oc_gsc' => "òc gascon",
152
-	'oc_lms' => "òc lemosin",
153
-	'oc_auv' => "òc auvernhat",
154
-	'oc_va' => "òc vivaroaupenc",
155
-	'om' => "(Afan) Oromo",
156
-	'or' => "Oriya",
157
-	'pa' => "Punjabi",
158
-	'pbb' => 'Nasa Yuwe',
159
-	'pl' => "polski",
160
-	'prs' => "دری", // ISO-639-3 Dari (Afghanistan)
161
-	'ps' => "پښتو",
162
-	'pt' => "Português",
163
-	'pt_br' => "Português do Brasil",
164
-	'qu' => "Quechua",
165
-	'rm' => "Rhaeto-Romance",
166
-	'rn' => "Kirundi",
167
-	'ro' => "română",
168
-	'roa' => "ch'ti",
169
-	'ru' => "русский",
170
-	'rw' => "Kinyarwanda",
171
-	'sa' => "संस्कृत",
172
-	'sc' => "sardu",
173
-	'scn' => "sicilianu",
174
-	'sd' => "Sindhi",
175
-	'sg' => "Sangho",
176
-	'sh' => "srpskohrvastski",
177
-	'sh_latn' => 'srpskohrvastski',
178
-	'sh_cyrl' => 'Српскохрватски',
179
-	'si' => "Sinhalese",
180
-	'sk' => "slovenčina",  // (Slovakia)
181
-	'sl' => "slovenščina",  // (Slovenia)
182
-	'sm' => "Samoan",
183
-	'sn' => "Shona",
184
-	'so' => "Somali",
185
-	'sq' => "shqip",
186
-	'sr' => "српски",
187
-	'src' => 'sardu logudorésu', // sarde cf 'sc'
188
-	'sro' => 'sardu campidanésu',
189
-	'ss' => "Siswati",
190
-	'st' => "Sesotho",
191
-	'su' => "Sundanese",
192
-	'sv' => "svenska",
193
-	'sw' => "Kiswahili",
194
-	'ta' => "தமிழ்", // Tamil
195
-	'te' => "Telugu",
196
-	'tg' => "Tajik",
197
-	'th' => "ไทย",
198
-	'ti' => "Tigrinya",
199
-	'tk' => "Turkmen",
200
-	'tl' => "Tagalog",
201
-	'tn' => "Setswana",
202
-	'to' => "Tonga",
203
-	'tr' => "Türkçe",
204
-	'ts' => "Tsonga",
205
-	'tt' => "Татар",
206
-	'tw' => "Twi",
207
-	'ty' => "reo mā`ohi", // tahitien
208
-	'ug' => "Uighur",
209
-	'uk' => "українська",
210
-	'ur' => "ٱردو",
211
-	'uz' => "O'zbekcha",
212
-	'vi' => "Tiếng Việt",
213
-	'vo' => "Volapuk",
214
-	'wa' => "walon",
215
-	'wo' => "Wolof",
216
-	'xh' => "Xhosa",
217
-	'yi' => "Yiddish",
218
-	'yo' => "Yoruba",
219
-	'za' => "Zhuang",
220
-	'zh' => "中文", // chinois (ecriture simplifiee)
221
-	'zh_tw' => "台灣中文", // chinois taiwan (ecr. traditionnelle)
222
-	'zu' => "Zulu"
26
+    'aa' => "Afar",
27
+    'ab' => "Abkhazian",
28
+    'af' => "Afrikaans",
29
+    'am' => "Amharic",
30
+    'an' => "Aragonés",
31
+    'ar' => "عربي",
32
+    'as' => "Assamese",
33
+    'ast' => "asturianu",
34
+    'ay' => "Aymara",
35
+    'az' => "Azərbaycan dili",
36
+    'ba' => "Bashkir",
37
+    'be' => "Беларуская",
38
+    'ber_tam' => "Tamazigh",
39
+    'ber_tam_tfng' => "Tamazigh tifinagh",
40
+    'bg' => "български",
41
+    'bh' => "Bihari",
42
+    'bi' => "Bislama",
43
+    'bm' => "Bambara",
44
+    'bn' => "Bengali; Bangla",
45
+    'bo' => "Tibetan",
46
+    'br' => "brezhoneg",
47
+    'bs' => "bosanski",
48
+    'ca' => "català",
49
+    'co' => "corsu",
50
+    'cpf' => "Kréol réyoné",
51
+    'cpf_dom' => "Kreyòl",
52
+    'cpf_hat' => "Kreyòl (Peyi Dayiti)",
53
+    'cs' => "čeština",
54
+    'cy' => "Cymraeg",  # welsh, gallois
55
+    'da' => "dansk",
56
+    'de' => "Deutsch",
57
+    'dz' => "Bhutani",
58
+    'el' => "ελληνικά",
59
+    'en' => "English",
60
+    'en_hx' => "H4ck3R",
61
+    'en_sm' => "Smurf",
62
+    'eo' => "Esperanto",
63
+    'es' => "Español",
64
+    'es_co' => "Colombiano",
65
+    'es_mx_pop' => "Mexicano a lo güey",
66
+    'et' => "eesti",
67
+    'eu' => "euskara",
68
+    'fa' => "فارسى",
69
+    'ff' => "Fulah", // peul
70
+    'fi' => "suomi",
71
+    'fj' => "Fiji",
72
+    'fo' => "føroyskt",
73
+    'fon' => "fongbè",
74
+    'fr' => "français",
75
+    'fr_fem' => "français féminin",
76
+    'fr_sc' => "schtroumpf",
77
+    'fr_lpc' => "langue parlée complétée",
78
+    'fr_lsf' => "langue des signes française",
79
+    'fr_spl' => "français simplifié",
80
+    'fr_tu' => "français copain",
81
+    'fy' => "Frisian",
82
+    'ga' => "Irish",
83
+    'gd' => "Scots Gaelic",
84
+    'gl' => "galego",
85
+    'gn' => "Guarani",
86
+    'grc' => "Ἀρχαία Ἑλληνική", // grec ancien
87
+    'gu' => "Gujarati",
88
+    'ha' => "Hausa",
89
+    'hac' => "ک-هۆرامی", //"Kurdish-Horami"
90
+    'hbo' => "עברית־התנך", // hebreu classique ou biblique
91
+    'haz' => "هزاره گی",
92
+    'he' => "עברית",
93
+    'hi' => "हिंदी",
94
+    'hr' => "hrvatski",
95
+    'hu' => "magyar",
96
+    'hy' => "Հայերեն",// Arménien
97
+    'ia' => "Interlingua",
98
+    'id' => "Indonesia",
99
+    'ie' => "Interlingue",
100
+    'ik' => "Inupiak",
101
+    'is' => "íslenska",
102
+    'it' => "italiano",
103
+    'it_fem' => "italiana",
104
+    'iu' => "Inuktitut",
105
+    'ja' => "日本語",
106
+    'jv' => "Javanese",
107
+    'ka' => "ქართული",
108
+    'kk' => "қазақ тілі", // Kazakh
109
+    'kl' => "kalaallisut",
110
+    'km' => "ភាសាខ្មែរ",// Khmer
111
+    'kn' => "Kannada",
112
+    'ko' => "한국어",
113
+    'kok' => "कोंकणी",
114
+    'ks' => "Kashmiri",
115
+    'ku' => "کوردی",
116
+    'ky' => "Kirghiz",
117
+    'la' => "lingua latina",
118
+    'lb' => "Lëtzebuergesch",
119
+    'ln' => "Lingala",
120
+    'lo' => "ພາສາລາວ", # lao
121
+    'lt' => "lietuvių",
122
+    'lu' => "luba-katanga",
123
+    'lv' => "latviešu",
124
+    'man' => "mandingue", # a traduire en mandingue
125
+    'mfv' => "manjak", # ISO-639-3
126
+    'mg' => "Malagasy",
127
+    'mi' => "Maori",
128
+    'mk' => "македонски јазик",
129
+    'ml' => "Malayalam",
130
+    'mn' => "Монгол хэл",
131
+    'mo' => "Moldavian",
132
+    'mos' => "Moré",
133
+    'mr' => "मराठी",
134
+    'ms' => "Bahasa Malaysia",
135
+    'mt' => "Maltese",
136
+    'my' => "Burmese",
137
+    'na' => "Nauru",
138
+    'nap' => "napulitano",
139
+    'ne' => "Nepali",
140
+    'nqo' => "N'ko", // www.manden.org
141
+    'nl' => "Nederlands",
142
+    'no' => "norsk",
143
+    'nb' => "norsk bokmål",
144
+    'nn' => "norsk nynorsk",
145
+    'oc' => "òc",
146
+    'oc_lnc' => "òc lengadocian",
147
+    'oc_ni' => "òc niçard",
148
+    'oc_ni_la' => "òc niçard (larg)",
149
+    'oc_ni_mis' => "òc nissart (mistralenc)",
150
+    'oc_prv' => "òc provençau",
151
+    'oc_gsc' => "òc gascon",
152
+    'oc_lms' => "òc lemosin",
153
+    'oc_auv' => "òc auvernhat",
154
+    'oc_va' => "òc vivaroaupenc",
155
+    'om' => "(Afan) Oromo",
156
+    'or' => "Oriya",
157
+    'pa' => "Punjabi",
158
+    'pbb' => 'Nasa Yuwe',
159
+    'pl' => "polski",
160
+    'prs' => "دری", // ISO-639-3 Dari (Afghanistan)
161
+    'ps' => "پښتو",
162
+    'pt' => "Português",
163
+    'pt_br' => "Português do Brasil",
164
+    'qu' => "Quechua",
165
+    'rm' => "Rhaeto-Romance",
166
+    'rn' => "Kirundi",
167
+    'ro' => "română",
168
+    'roa' => "ch'ti",
169
+    'ru' => "русский",
170
+    'rw' => "Kinyarwanda",
171
+    'sa' => "संस्कृत",
172
+    'sc' => "sardu",
173
+    'scn' => "sicilianu",
174
+    'sd' => "Sindhi",
175
+    'sg' => "Sangho",
176
+    'sh' => "srpskohrvastski",
177
+    'sh_latn' => 'srpskohrvastski',
178
+    'sh_cyrl' => 'Српскохрватски',
179
+    'si' => "Sinhalese",
180
+    'sk' => "slovenčina",  // (Slovakia)
181
+    'sl' => "slovenščina",  // (Slovenia)
182
+    'sm' => "Samoan",
183
+    'sn' => "Shona",
184
+    'so' => "Somali",
185
+    'sq' => "shqip",
186
+    'sr' => "српски",
187
+    'src' => 'sardu logudorésu', // sarde cf 'sc'
188
+    'sro' => 'sardu campidanésu',
189
+    'ss' => "Siswati",
190
+    'st' => "Sesotho",
191
+    'su' => "Sundanese",
192
+    'sv' => "svenska",
193
+    'sw' => "Kiswahili",
194
+    'ta' => "தமிழ்", // Tamil
195
+    'te' => "Telugu",
196
+    'tg' => "Tajik",
197
+    'th' => "ไทย",
198
+    'ti' => "Tigrinya",
199
+    'tk' => "Turkmen",
200
+    'tl' => "Tagalog",
201
+    'tn' => "Setswana",
202
+    'to' => "Tonga",
203
+    'tr' => "Türkçe",
204
+    'ts' => "Tsonga",
205
+    'tt' => "Татар",
206
+    'tw' => "Twi",
207
+    'ty' => "reo mā`ohi", // tahitien
208
+    'ug' => "Uighur",
209
+    'uk' => "українська",
210
+    'ur' => "ٱردو",
211
+    'uz' => "O'zbekcha",
212
+    'vi' => "Tiếng Việt",
213
+    'vo' => "Volapuk",
214
+    'wa' => "walon",
215
+    'wo' => "Wolof",
216
+    'xh' => "Xhosa",
217
+    'yi' => "Yiddish",
218
+    'yo' => "Yoruba",
219
+    'za' => "Zhuang",
220
+    'zh' => "中文", // chinois (ecriture simplifiee)
221
+    'zh_tw' => "台灣中文", // chinois taiwan (ecr. traditionnelle)
222
+    'zu' => "Zulu"
223 223
 
224 224
 );
Please login to merge, or discard this patch.
ecrire/inc/json.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		case is_null($var):
32 32
 			return 'null';
33 33
 		case is_string($var):
34
-			return '"' . addcslashes($var, "\"\\\n\r/") . '"';
34
+			return '"'.addcslashes($var, "\"\\\n\r/").'"';
35 35
 		case is_bool($var):
36 36
 			return $var ? 'true' : 'false';
37 37
 		case is_scalar($var):
38
-			return (string)$var;
38
+			return (string) $var;
39 39
 		case is_object($var):// blam
40 40
 			$var = get_object_vars($var);
41 41
 			$asso = true;
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 			if ($asso) {
51 51
 				$ret = '{';
52 52
 				foreach ($var as $key => $elt) {
53
-					$ret .= $sep . '"' . $key . '":' . var2js($elt);
53
+					$ret .= $sep.'"'.$key.'":'.var2js($elt);
54 54
 					$sep = ',';
55 55
 				}
56 56
 
57
-				return $ret . '}';
57
+				return $ret.'}';
58 58
 			} else {
59 59
 				$ret = '[';
60 60
 				foreach ($var as $elt) {
61
-					$ret .= $sep . var2js($elt);
61
+					$ret .= $sep.var2js($elt);
62 62
 					$sep = ',';
63 63
 				}
64 64
 
65
-				return $ret . ']';
65
+				return $ret.']';
66 66
 			}
67 67
 	}
68 68
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	// flag indiquant qu'on est en iframe et qu'il faut proteger nos
83 83
 	// donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84 84
 	if (defined('FILE_UPLOAD')) {
85
-		return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
85
+		return '<textarea>'.spip_htmlspecialchars($var).'</textarea>';
86 86
 	} else {
87 87
 		return $var;
88 88
 	}
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // Les fonctions de toggg pour faire du JSON
@@ -26,64 +26,64 @@  discard block
 block discarded – undo
26 26
 
27 27
 // https://code.spip.net/@var2js
28 28
 function var2js($var) {
29
-	$asso = false;
30
-	switch (true) {
31
-		case is_null($var):
32
-			return 'null';
33
-		case is_string($var):
34
-			return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
-		case is_bool($var):
36
-			return $var ? 'true' : 'false';
37
-		case is_scalar($var):
38
-			return (string)$var;
39
-		case is_object($var):// blam
40
-			$var = get_object_vars($var);
41
-			$asso = true;
42
-			// $var devient un array, on continue
43
-		case is_array($var):
44
-			$keys = array_keys($var);
45
-			$ikey = count($keys);
46
-			while (!$asso && $ikey--) {
47
-				$asso = $ikey !== $keys[$ikey];
48
-			}
49
-			$sep = '';
50
-			if ($asso) {
51
-				$ret = '{';
52
-				foreach ($var as $key => $elt) {
53
-					$ret .= $sep . '"' . $key . '":' . var2js($elt);
54
-					$sep = ',';
55
-				}
29
+    $asso = false;
30
+    switch (true) {
31
+        case is_null($var):
32
+            return 'null';
33
+        case is_string($var):
34
+            return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
+        case is_bool($var):
36
+            return $var ? 'true' : 'false';
37
+        case is_scalar($var):
38
+            return (string)$var;
39
+        case is_object($var):// blam
40
+            $var = get_object_vars($var);
41
+            $asso = true;
42
+            // $var devient un array, on continue
43
+        case is_array($var):
44
+            $keys = array_keys($var);
45
+            $ikey = count($keys);
46
+            while (!$asso && $ikey--) {
47
+                $asso = $ikey !== $keys[$ikey];
48
+            }
49
+            $sep = '';
50
+            if ($asso) {
51
+                $ret = '{';
52
+                foreach ($var as $key => $elt) {
53
+                    $ret .= $sep . '"' . $key . '":' . var2js($elt);
54
+                    $sep = ',';
55
+                }
56 56
 
57
-				return $ret . '}';
58
-			} else {
59
-				$ret = '[';
60
-				foreach ($var as $elt) {
61
-					$ret .= $sep . var2js($elt);
62
-					$sep = ',';
63
-				}
57
+                return $ret . '}';
58
+            } else {
59
+                $ret = '[';
60
+                foreach ($var as $elt) {
61
+                    $ret .= $sep . var2js($elt);
62
+                    $sep = ',';
63
+                }
64 64
 
65
-				return $ret . ']';
66
-			}
67
-	}
65
+                return $ret . ']';
66
+            }
67
+    }
68 68
 
69
-	return false;
69
+    return false;
70 70
 }
71 71
 
72 72
 if (!function_exists('json_encode')) {
73
-	function json_encode($v) {
74
-		return var2js($v);
75
-	}
73
+    function json_encode($v) {
74
+        return var2js($v);
75
+    }
76 76
 }
77 77
 
78 78
 // https://code.spip.net/@json_export
79 79
 function json_export($var) {
80
-	$var = json_encode($var);
80
+    $var = json_encode($var);
81 81
 
82
-	// flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
-	// donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
-	if (defined('FILE_UPLOAD')) {
85
-		return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
-	} else {
87
-		return $var;
88
-	}
82
+    // flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
+    // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
+    if (defined('FILE_UPLOAD')) {
85
+        return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
+    } else {
87
+        return $var;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
ecrire/inc/config.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			if (strncmp($url, 'configurer_', 11) == 0) {
341 341
 				$deja[$url] = $b;
342 342
 			} elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) {
343
-				$deja["configurer_" . $match[1]] = $b;
343
+				$deja["configurer_".$match[1]] = $b;
344 344
 			}
345 345
 		}
346 346
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 
355 355
 	// trouver toutes les pages configurer_xxx de l'espace prive
356 356
 	// et construire un tableau des entrees qui ne sont pas dans $deja
357
-	$pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
357
+	$pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$');
358 358
 
359 359
 	foreach ($pages as $page) {
360
-		$configurer = basename($page, "." . _EXTENSION_SQUELETTES);
360
+		$configurer = basename($page, "."._EXTENSION_SQUELETTES);
361 361
 		if (!isset($exclure[$configurer])) {
362 362
 			$liste[$configurer] = array(
363 363
 				'parent' => 'bando_configuration',
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
 
378 378
 	// trouver tous les formulaires/configurer_
379 379
 	// et construire un tableau des entrees
380
-	$pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
380
+	$pages = find_all_in_path("formulaires/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$');
381 381
 	foreach ($pages as $page) {
382
-		$configurer = basename($page, "." . _EXTENSION_SQUELETTES);
382
+		$configurer = basename($page, "."._EXTENSION_SQUELETTES);
383 383
 		if (!isset($forms[$configurer])
384 384
 			and !isset($liste[$configurer])
385 385
 			and !isset($exclure[$configurer])
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			$liste[$configurer] = array(
388 388
 				'parent' => 'bando_configuration',
389 389
 				'url' => 'configurer',
390
-				'args' => 'cfg=' . substr($configurer, 11),
390
+				'args' => 'cfg='.substr($configurer, 11),
391 391
 				'titre' => _T("configurer:{$configurer}_titre"),
392 392
 				'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
393 393
 			);
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 
420 420
 	// evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent
421 421
 	// et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline
422
-	$config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES)));
423
-	spip_log('Calcul de ' . "prive/squelettes/contenu/$config");
422
+	$config = basename(substr($file, 0, -strlen("."._EXTENSION_SQUELETTES)));
423
+	spip_log('Calcul de '."prive/squelettes/contenu/$config");
424 424
 	$fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config));
425 425
 
426 426
 	// passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires...
Please login to merge, or discard this patch.
Indentation   +400 added lines, -400 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
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * @return void
29 29
  */
30 30
 function inc_config_dist() {
31
-	actualise_metas(liste_metas());
31
+    actualise_metas(liste_metas());
32 32
 }
33 33
 
34 34
 /**
@@ -45,34 +45,34 @@  discard block
 block discarded – undo
45 45
  *     Liste (table, casier, sous_casier)
46 46
  */
47 47
 function expliquer_config($cfg) {
48
-	// par defaut, sur la table des meta
49
-	$table = 'meta';
50
-	$casier = null;
51
-	$sous_casier = array();
52
-	$cfg = explode('/', $cfg);
53
-
54
-	// si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide ''
55
-	if (!reset($cfg) and count($cfg) > 1) {
56
-		array_shift($cfg);
57
-		$table = array_shift($cfg);
58
-		if (!isset($GLOBALS[$table])) {
59
-			lire_metas($table);
60
-		}
61
-	}
62
-
63
-	// si on a demande #CONFIG{/meta,'',0}
64
-	if (count($cfg)) {
65
-		// pas sur un appel vide ''
66
-		if ('' !== ($c = array_shift($cfg))) {
67
-			$casier = $c;
68
-		}
69
-	}
70
-
71
-	if (count($cfg)) {
72
-		$sous_casier = $cfg;
73
-	}
74
-
75
-	return array($table, $casier, $sous_casier);
48
+    // par defaut, sur la table des meta
49
+    $table = 'meta';
50
+    $casier = null;
51
+    $sous_casier = array();
52
+    $cfg = explode('/', $cfg);
53
+
54
+    // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide ''
55
+    if (!reset($cfg) and count($cfg) > 1) {
56
+        array_shift($cfg);
57
+        $table = array_shift($cfg);
58
+        if (!isset($GLOBALS[$table])) {
59
+            lire_metas($table);
60
+        }
61
+    }
62
+
63
+    // si on a demande #CONFIG{/meta,'',0}
64
+    if (count($cfg)) {
65
+        // pas sur un appel vide ''
66
+        if ('' !== ($c = array_shift($cfg))) {
67
+            $casier = $c;
68
+        }
69
+    }
70
+
71
+    if (count($cfg)) {
72
+        $sous_casier = $cfg;
73
+    }
74
+
75
+    return array($table, $casier, $sous_casier);
76 76
 }
77 77
 
78 78
 /**
@@ -100,65 +100,65 @@  discard block
 block discarded – undo
100 100
  *    Contenu de la configuration obtenue
101 101
  */
102 102
 function lire_config($cfg = '', $def = null, $unserialize = true) {
103
-	// lire le stockage sous la forme /table/valeur
104
-	// ou valeur qui est en fait implicitement /meta/valeur
105
-	// ou casier/valeur qui est en fait implicitement /meta/casier/valeur
106
-
107
-	// traiter en priorite le cas simple et frequent
108
-	// de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni :
109
-	if ($cfg and strpbrk($cfg, '/:') === false) {
110
-		$r = isset($GLOBALS['meta'][$cfg]) ?
111
-			((!$unserialize
112
-				// ne pas essayer de deserialiser autre chose qu'une chaine
113
-				or !is_string($GLOBALS['meta'][$cfg])
114
-				// ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee
115
-				or strpos($GLOBALS['meta'][$cfg], ':') === false
116
-				or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t)
117
-			: $def;
118
-
119
-		return $r;
120
-	}
121
-
122
-	// Brancher sur methodes externes si besoin
123
-	if ($cfg and $p = strpos($cfg, '::')) {
124
-		$methode = substr($cfg, 0, $p);
125
-		$lire_config = charger_fonction($methode, 'lire_config');
126
-
127
-		return $lire_config(substr($cfg, $p + 2), $def, $unserialize);
128
-	}
129
-
130
-	list($table, $casier, $sous_casier) = expliquer_config($cfg);
131
-
132
-	if (!isset($GLOBALS[$table])) {
133
-		return $def;
134
-	}
135
-
136
-	$r = $GLOBALS[$table];
137
-
138
-	// si on a demande #CONFIG{/meta,'',0}
139
-	if (!$casier) {
140
-		return $unserialize ? $r : serialize($r);
141
-	}
142
-
143
-	// casier principal :
144
-	// le deserializer si demande
145
-	// ou si on a besoin
146
-	// d'un sous casier
147
-	$r = isset($r[$casier]) ? $r[$casier] : null;
148
-	if (($unserialize or count($sous_casier)) and $r and is_string($r)) {
149
-		$r = (($t = @unserialize($r)) === false ? $r : $t);
150
-	}
151
-
152
-	// aller chercher le sous_casier
153
-	while (!is_null($r) and $casier = array_shift($sous_casier)) {
154
-		$r = isset($r[$casier]) ? $r[$casier] : null;
155
-	}
156
-
157
-	if (is_null($r)) {
158
-		return $def;
159
-	}
160
-
161
-	return $r;
103
+    // lire le stockage sous la forme /table/valeur
104
+    // ou valeur qui est en fait implicitement /meta/valeur
105
+    // ou casier/valeur qui est en fait implicitement /meta/casier/valeur
106
+
107
+    // traiter en priorite le cas simple et frequent
108
+    // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni :
109
+    if ($cfg and strpbrk($cfg, '/:') === false) {
110
+        $r = isset($GLOBALS['meta'][$cfg]) ?
111
+            ((!$unserialize
112
+                // ne pas essayer de deserialiser autre chose qu'une chaine
113
+                or !is_string($GLOBALS['meta'][$cfg])
114
+                // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee
115
+                or strpos($GLOBALS['meta'][$cfg], ':') === false
116
+                or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t)
117
+            : $def;
118
+
119
+        return $r;
120
+    }
121
+
122
+    // Brancher sur methodes externes si besoin
123
+    if ($cfg and $p = strpos($cfg, '::')) {
124
+        $methode = substr($cfg, 0, $p);
125
+        $lire_config = charger_fonction($methode, 'lire_config');
126
+
127
+        return $lire_config(substr($cfg, $p + 2), $def, $unserialize);
128
+    }
129
+
130
+    list($table, $casier, $sous_casier) = expliquer_config($cfg);
131
+
132
+    if (!isset($GLOBALS[$table])) {
133
+        return $def;
134
+    }
135
+
136
+    $r = $GLOBALS[$table];
137
+
138
+    // si on a demande #CONFIG{/meta,'',0}
139
+    if (!$casier) {
140
+        return $unserialize ? $r : serialize($r);
141
+    }
142
+
143
+    // casier principal :
144
+    // le deserializer si demande
145
+    // ou si on a besoin
146
+    // d'un sous casier
147
+    $r = isset($r[$casier]) ? $r[$casier] : null;
148
+    if (($unserialize or count($sous_casier)) and $r and is_string($r)) {
149
+        $r = (($t = @unserialize($r)) === false ? $r : $t);
150
+    }
151
+
152
+    // aller chercher le sous_casier
153
+    while (!is_null($r) and $casier = array_shift($sous_casier)) {
154
+        $r = isset($r[$casier]) ? $r[$casier] : null;
155
+    }
156
+
157
+    if (is_null($r)) {
158
+        return $def;
159
+    }
160
+
161
+    return $r;
162 162
 }
163 163
 
164 164
 /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
  * @return mixed
173 173
  */
174 174
 function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) {
175
-	return lire_config($cfg, $def, $unserialize);
175
+    return lire_config($cfg, $def, $unserialize);
176 176
 }
177 177
 
178 178
 
@@ -184,98 +184,98 @@  discard block
 block discarded – undo
184 184
  * @return bool
185 185
  */
186 186
 function ecrire_config($cfg, $store) {
187
-	// Brancher sur methodes externes si besoin
188
-	if ($cfg and $p = strpos($cfg, '::')) {
189
-		$methode = substr($cfg, 0, $p);
190
-		$ecrire_config = charger_fonction($methode, 'ecrire_config');
191
-
192
-		return $ecrire_config(substr($cfg, $p + 2), $store);
193
-	}
194
-
195
-	list($table, $casier, $sous_casier) = expliquer_config($cfg);
196
-	// il faut au moins un casier pour ecrire
197
-	if (!$casier) {
198
-		return false;
199
-	}
200
-
201
-	// trouvons ou creons le pointeur sur le casier
202
-	$st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null;
203
-	if (!is_array($st) and ($sous_casier or is_array($store))) {
204
-		$st = unserialize($st);
205
-		if ($st === false) {
206
-			// ne rien creer si c'est une demande d'effacement
207
-			if (is_null($store)) {
208
-				return false;
209
-			}
210
-			$st = array();
211
-		}
212
-	}
213
-
214
-	// si on a affaire a un sous caiser
215
-	// il faut ecrire au bon endroit sans perdre les autres sous casier freres
216
-	if ($c = $sous_casier) {
217
-		$sc = &$st;
218
-		$pointeurs = array();
219
-		while (count($c) and $cc = array_shift($c)) {
220
-			// creer l'entree si elle n'existe pas
221
-			if (!isset($sc[$cc])) {
222
-				// si on essaye d'effacer une config qui n'existe pas
223
-				// ne rien creer mais sortir
224
-				if (is_null($store)) {
225
-					return false;
226
-				}
227
-				$sc[$cc] = array();
228
-			}
229
-			$pointeurs[$cc] = &$sc;
230
-			$sc = &$sc[$cc];
231
-		}
232
-
233
-		// si c'est une demande d'effacement
234
-		if (is_null($store)) {
235
-			$c = $sous_casier;
236
-			$sous = array_pop($c);
237
-			// effacer, et remonter pour effacer les parents vides
238
-			do {
239
-				unset($pointeurs[$sous][$sous]);
240
-			} while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous]));
241
-
242
-			// si on a vide tous les sous casiers,
243
-			// et que le casier est vide
244
-			// vider aussi la meta
245
-			if (!$sous and !count($st)) {
246
-				$st = null;
247
-			}
248
-		} // dans tous les autres cas, on ecrase
249
-		else {
250
-			$sc = $store;
251
-		}
252
-
253
-		// Maintenant que $st est modifiee
254
-		// reprenons la comme valeur a stocker dans le casier principal
255
-		$store = $st;
256
-	}
257
-
258
-	if (is_null($store)) {
259
-		if (is_null($st) and !$sous_casier) {
260
-			return false;
261
-		} // la config n'existait deja pas !
262
-		effacer_meta($casier, $table);
263
-		supprimer_table_meta($table); // supprimons la table (si elle est bien vide)
264
-	} // les meta ne peuvent etre que des chaines : il faut serializer le reste
265
-	else {
266
-		if (!isset($GLOBALS[$table])) {
267
-			installer_table_meta($table);
268
-		}
269
-		// si ce n'est pas une chaine
270
-		// il faut serializer
271
-		if (!is_string($store)) {
272
-			$store = serialize($store);
273
-		}
274
-		ecrire_meta($casier, $store, null, $table);
275
-	}
276
-
277
-	// verifier que lire_config($cfg)==$store ?
278
-	return true;
187
+    // Brancher sur methodes externes si besoin
188
+    if ($cfg and $p = strpos($cfg, '::')) {
189
+        $methode = substr($cfg, 0, $p);
190
+        $ecrire_config = charger_fonction($methode, 'ecrire_config');
191
+
192
+        return $ecrire_config(substr($cfg, $p + 2), $store);
193
+    }
194
+
195
+    list($table, $casier, $sous_casier) = expliquer_config($cfg);
196
+    // il faut au moins un casier pour ecrire
197
+    if (!$casier) {
198
+        return false;
199
+    }
200
+
201
+    // trouvons ou creons le pointeur sur le casier
202
+    $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null;
203
+    if (!is_array($st) and ($sous_casier or is_array($store))) {
204
+        $st = unserialize($st);
205
+        if ($st === false) {
206
+            // ne rien creer si c'est une demande d'effacement
207
+            if (is_null($store)) {
208
+                return false;
209
+            }
210
+            $st = array();
211
+        }
212
+    }
213
+
214
+    // si on a affaire a un sous caiser
215
+    // il faut ecrire au bon endroit sans perdre les autres sous casier freres
216
+    if ($c = $sous_casier) {
217
+        $sc = &$st;
218
+        $pointeurs = array();
219
+        while (count($c) and $cc = array_shift($c)) {
220
+            // creer l'entree si elle n'existe pas
221
+            if (!isset($sc[$cc])) {
222
+                // si on essaye d'effacer une config qui n'existe pas
223
+                // ne rien creer mais sortir
224
+                if (is_null($store)) {
225
+                    return false;
226
+                }
227
+                $sc[$cc] = array();
228
+            }
229
+            $pointeurs[$cc] = &$sc;
230
+            $sc = &$sc[$cc];
231
+        }
232
+
233
+        // si c'est une demande d'effacement
234
+        if (is_null($store)) {
235
+            $c = $sous_casier;
236
+            $sous = array_pop($c);
237
+            // effacer, et remonter pour effacer les parents vides
238
+            do {
239
+                unset($pointeurs[$sous][$sous]);
240
+            } while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous]));
241
+
242
+            // si on a vide tous les sous casiers,
243
+            // et que le casier est vide
244
+            // vider aussi la meta
245
+            if (!$sous and !count($st)) {
246
+                $st = null;
247
+            }
248
+        } // dans tous les autres cas, on ecrase
249
+        else {
250
+            $sc = $store;
251
+        }
252
+
253
+        // Maintenant que $st est modifiee
254
+        // reprenons la comme valeur a stocker dans le casier principal
255
+        $store = $st;
256
+    }
257
+
258
+    if (is_null($store)) {
259
+        if (is_null($st) and !$sous_casier) {
260
+            return false;
261
+        } // la config n'existait deja pas !
262
+        effacer_meta($casier, $table);
263
+        supprimer_table_meta($table); // supprimons la table (si elle est bien vide)
264
+    } // les meta ne peuvent etre que des chaines : il faut serializer le reste
265
+    else {
266
+        if (!isset($GLOBALS[$table])) {
267
+            installer_table_meta($table);
268
+        }
269
+        // si ce n'est pas une chaine
270
+        // il faut serializer
271
+        if (!is_string($store)) {
272
+            $store = serialize($store);
273
+        }
274
+        ecrire_meta($casier, $store, null, $table);
275
+    }
276
+
277
+    // verifier que lire_config($cfg)==$store ?
278
+    return true;
279 279
 }
280 280
 
281 281
 
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
  * @return bool
290 290
  */
291 291
 function ecrire_config_metapack_dist($cfg, $store) {
292
-	// cas particulier en metapack::
293
-	// si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre
294
-	// intacte en sortie ...
295
-	if (is_string($store) and strpos($store, ':') and unserialize($store)) {
296
-		$store = serialize($store);
297
-	}
298
-
299
-	return ecrire_config($cfg, $store);
292
+    // cas particulier en metapack::
293
+    // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre
294
+    // intacte en sortie ...
295
+    if (is_string($store) and strpos($store, ':') and unserialize($store)) {
296
+        $store = serialize($store);
297
+    }
298
+
299
+    return ecrire_config($cfg, $store);
300 300
 }
301 301
 
302 302
 /**
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
  * @return bool
307 307
  */
308 308
 function effacer_config($cfg) {
309
-	ecrire_config($cfg, null);
309
+    ecrire_config($cfg, null);
310 310
 
311
-	return true;
311
+    return true;
312 312
 }
313 313
 
314 314
 /**
@@ -325,71 +325,71 @@  discard block
 block discarded – undo
325 325
  * @return array
326 326
  */
327 327
 function lister_configurer($exclure = array()) {
328
-	return array();
329
-
330
-	// lister les pages de config deja dans les menus
331
-	$deja = array();
332
-	foreach ($exclure as $id => $b) {
333
-		$url = ($b['url'] ? $b['url'] : $id);
334
-		if (!$b['url'] or !isset($exclure[$url])) {
335
-			if (strncmp($url, 'configurer_', 11) == 0) {
336
-				$deja[$url] = $b;
337
-			} elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) {
338
-				$deja["configurer_" . $match[1]] = $b;
339
-			}
340
-		}
341
-
342
-	}
343
-	$exclure = $exclure + $deja;
344
-
345
-	$icone_defaut = "images/configuration-16.png";
346
-	$liste = array();
347
-	$skels = array();
348
-	$forms = array();
349
-
350
-	// trouver toutes les pages configurer_xxx de l'espace prive
351
-	// et construire un tableau des entrees qui ne sont pas dans $deja
352
-	$pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
353
-
354
-	foreach ($pages as $page) {
355
-		$configurer = basename($page, "." . _EXTENSION_SQUELETTES);
356
-		if (!isset($exclure[$configurer])) {
357
-			$liste[$configurer] = array(
358
-				'parent' => 'bando_configuration',
359
-				'url' => $configurer,
360
-				'titre' => _T("configurer:{$configurer}_titre"),
361
-				'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
362
-			);
363
-		}
364
-		$skels[$configurer] = $page;
365
-	}
366
-
367
-	// analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus
368
-	foreach ($skels as $file) {
369
-		$forms = array_merge($forms, lister_formulaires_configurer($file));
370
-	}
371
-	$forms = array_flip($forms);
372
-
373
-	// trouver tous les formulaires/configurer_
374
-	// et construire un tableau des entrees
375
-	$pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
376
-	foreach ($pages as $page) {
377
-		$configurer = basename($page, "." . _EXTENSION_SQUELETTES);
378
-		if (!isset($forms[$configurer])
379
-			and !isset($liste[$configurer])
380
-			and !isset($exclure[$configurer])
381
-		) {
382
-			$liste[$configurer] = array(
383
-				'parent' => 'bando_configuration',
384
-				'url' => 'configurer',
385
-				'args' => 'cfg=' . substr($configurer, 11),
386
-				'titre' => _T("configurer:{$configurer}_titre"),
387
-				'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
388
-			);
389
-		}
390
-	}
391
-
392
-	return $liste;
328
+    return array();
329
+
330
+    // lister les pages de config deja dans les menus
331
+    $deja = array();
332
+    foreach ($exclure as $id => $b) {
333
+        $url = ($b['url'] ? $b['url'] : $id);
334
+        if (!$b['url'] or !isset($exclure[$url])) {
335
+            if (strncmp($url, 'configurer_', 11) == 0) {
336
+                $deja[$url] = $b;
337
+            } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) {
338
+                $deja["configurer_" . $match[1]] = $b;
339
+            }
340
+        }
341
+
342
+    }
343
+    $exclure = $exclure + $deja;
344
+
345
+    $icone_defaut = "images/configuration-16.png";
346
+    $liste = array();
347
+    $skels = array();
348
+    $forms = array();
349
+
350
+    // trouver toutes les pages configurer_xxx de l'espace prive
351
+    // et construire un tableau des entrees qui ne sont pas dans $deja
352
+    $pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
353
+
354
+    foreach ($pages as $page) {
355
+        $configurer = basename($page, "." . _EXTENSION_SQUELETTES);
356
+        if (!isset($exclure[$configurer])) {
357
+            $liste[$configurer] = array(
358
+                'parent' => 'bando_configuration',
359
+                'url' => $configurer,
360
+                'titre' => _T("configurer:{$configurer}_titre"),
361
+                'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
362
+            );
363
+        }
364
+        $skels[$configurer] = $page;
365
+    }
366
+
367
+    // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus
368
+    foreach ($skels as $file) {
369
+        $forms = array_merge($forms, lister_formulaires_configurer($file));
370
+    }
371
+    $forms = array_flip($forms);
372
+
373
+    // trouver tous les formulaires/configurer_
374
+    // et construire un tableau des entrees
375
+    $pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$');
376
+    foreach ($pages as $page) {
377
+        $configurer = basename($page, "." . _EXTENSION_SQUELETTES);
378
+        if (!isset($forms[$configurer])
379
+            and !isset($liste[$configurer])
380
+            and !isset($exclure[$configurer])
381
+        ) {
382
+            $liste[$configurer] = array(
383
+                'parent' => 'bando_configuration',
384
+                'url' => 'configurer',
385
+                'args' => 'cfg=' . substr($configurer, 11),
386
+                'titre' => _T("configurer:{$configurer}_titre"),
387
+                'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
388
+            );
389
+        }
390
+    }
391
+
392
+    return $liste;
393 393
 }
394 394
 
395 395
 
@@ -403,35 +403,35 @@  discard block
 block discarded – undo
403 403
  *    Liste des formulaires trouvés
404 404
  **/
405 405
 function lister_formulaires_configurer($file) {
406
-	$forms = array();
407
-
408
-	lire_fichier($file, $skel);
409
-	if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches, PREG_SET_ORDER)) {
410
-		$matches = array_map('end', $matches);
411
-		$matches = array_map('strtolower', $matches);
412
-		$forms = array_merge($forms, $matches);
413
-	}
414
-
415
-	// evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent
416
-	// et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline
417
-	$config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES)));
418
-	spip_log('Calcul de ' . "prive/squelettes/contenu/$config");
419
-	$fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config));
420
-
421
-	// passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires...
422
-	// et donc que l'on puisse les referencer aussi !
423
-	$fond = pipeline('affiche_milieu', array('args' => array("exec" => $config), 'data' => $fond));
424
-
425
-	// recuperer les noms des formulaires presents.
426
-	if (is_array($inputs = extraire_balises($fond, "input"))) {
427
-		foreach ($inputs as $i) {
428
-			if (extraire_attribut($i, 'name') == 'formulaire_action') {
429
-				$forms[] = ($c = extraire_attribut($i, 'value'));
430
-			}
431
-		}
432
-	}
433
-
434
-	return $forms;
406
+    $forms = array();
407
+
408
+    lire_fichier($file, $skel);
409
+    if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches, PREG_SET_ORDER)) {
410
+        $matches = array_map('end', $matches);
411
+        $matches = array_map('strtolower', $matches);
412
+        $forms = array_merge($forms, $matches);
413
+    }
414
+
415
+    // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent
416
+    // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline
417
+    $config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES)));
418
+    spip_log('Calcul de ' . "prive/squelettes/contenu/$config");
419
+    $fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config));
420
+
421
+    // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires...
422
+    // et donc que l'on puisse les referencer aussi !
423
+    $fond = pipeline('affiche_milieu', array('args' => array("exec" => $config), 'data' => $fond));
424
+
425
+    // recuperer les noms des formulaires presents.
426
+    if (is_array($inputs = extraire_balises($fond, "input"))) {
427
+        foreach ($inputs as $i) {
428
+            if (extraire_attribut($i, 'name') == 'formulaire_action') {
429
+                $forms[] = ($c = extraire_attribut($i, 'value'));
430
+            }
431
+        }
432
+    }
433
+
434
+    return $forms;
435 435
 }
436 436
 
437 437
 
@@ -449,58 +449,58 @@  discard block
 block discarded – undo
449 449
  *    Couples nom de la `meta` => valeur par défaut
450 450
  */
451 451
 function liste_metas() {
452
-	return pipeline('configurer_liste_metas', array(
453
-		'nom_site' => _T('info_mon_site_spip'),
454
-		'slogan_site' => '',
455
-		'adresse_site' => preg_replace(",/$,", "", url_de_base()),
456
-		'descriptif_site' => '',
457
-		'activer_logos' => 'oui',
458
-		'activer_logos_survol' => 'non',
459
-		'articles_surtitre' => 'non',
460
-		'articles_soustitre' => 'non',
461
-		'articles_descriptif' => 'non',
462
-		'articles_chapeau' => 'non',
463
-		'articles_texte' => 'oui',
464
-		'articles_ps' => 'non',
465
-		'articles_redac' => 'non',
466
-		'post_dates' => 'non',
467
-		'articles_urlref' => 'non',
468
-		'articles_redirection' => 'non',
469
-		'creer_preview' => 'non',
470
-		'taille_preview' => 150,
471
-		'articles_modif' => 'non',
472
-
473
-		'rubriques_descriptif' => 'non',
474
-		'rubriques_texte' => 'oui',
475
-
476
-		'accepter_inscriptions' => 'non',
477
-		'accepter_visiteurs' => 'non',
478
-		'prevenir_auteurs' => 'non',
479
-		'suivi_edito' => 'non',
480
-		'adresse_suivi' => '',
481
-		'adresse_suivi_inscription' => '',
482
-		'adresse_neuf' => '',
483
-		'jours_neuf' => '',
484
-		'quoi_de_neuf' => 'non',
485
-		'preview' => ',0minirezo,1comite,',
486
-
487
-		'syndication_integrale' => 'oui',
488
-		'charset' => _DEFAULT_CHARSET,
489
-		'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)),
490
-
491
-		'multi_rubriques' => 'non',
492
-		'multi_secteurs' => 'non',
493
-		'gerer_trad' => 'non',
494
-		'langues_multilingue' => '',
495
-
496
-		'version_html_max' => 'html4',
497
-
498
-		'type_urls' => 'page',
499
-
500
-		'email_envoi' => '',
501
-		'email_webmaster' => '',
502
-		'auto_compress_http' => 'non',
503
-	));
452
+    return pipeline('configurer_liste_metas', array(
453
+        'nom_site' => _T('info_mon_site_spip'),
454
+        'slogan_site' => '',
455
+        'adresse_site' => preg_replace(",/$,", "", url_de_base()),
456
+        'descriptif_site' => '',
457
+        'activer_logos' => 'oui',
458
+        'activer_logos_survol' => 'non',
459
+        'articles_surtitre' => 'non',
460
+        'articles_soustitre' => 'non',
461
+        'articles_descriptif' => 'non',
462
+        'articles_chapeau' => 'non',
463
+        'articles_texte' => 'oui',
464
+        'articles_ps' => 'non',
465
+        'articles_redac' => 'non',
466
+        'post_dates' => 'non',
467
+        'articles_urlref' => 'non',
468
+        'articles_redirection' => 'non',
469
+        'creer_preview' => 'non',
470
+        'taille_preview' => 150,
471
+        'articles_modif' => 'non',
472
+
473
+        'rubriques_descriptif' => 'non',
474
+        'rubriques_texte' => 'oui',
475
+
476
+        'accepter_inscriptions' => 'non',
477
+        'accepter_visiteurs' => 'non',
478
+        'prevenir_auteurs' => 'non',
479
+        'suivi_edito' => 'non',
480
+        'adresse_suivi' => '',
481
+        'adresse_suivi_inscription' => '',
482
+        'adresse_neuf' => '',
483
+        'jours_neuf' => '',
484
+        'quoi_de_neuf' => 'non',
485
+        'preview' => ',0minirezo,1comite,',
486
+
487
+        'syndication_integrale' => 'oui',
488
+        'charset' => _DEFAULT_CHARSET,
489
+        'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)),
490
+
491
+        'multi_rubriques' => 'non',
492
+        'multi_secteurs' => 'non',
493
+        'gerer_trad' => 'non',
494
+        'langues_multilingue' => '',
495
+
496
+        'version_html_max' => 'html4',
497
+
498
+        'type_urls' => 'page',
499
+
500
+        'email_envoi' => '',
501
+        'email_webmaster' => '',
502
+        'auto_compress_http' => 'non',
503
+    ));
504 504
 }
505 505
 
506 506
 /**
@@ -511,43 +511,43 @@  discard block
 block discarded – undo
511 511
  * @return void
512 512
  */
513 513
 function actualise_metas($liste_meta) {
514
-	$meta_serveur =
515
-		array(
516
-			'version_installee',
517
-			'adresse_site',
518
-			'alea_ephemere_ancien',
519
-			'alea_ephemere',
520
-			'alea_ephemere_date',
521
-			'langue_site',
522
-			'langues_proposees',
523
-			'date_calcul_rubriques',
524
-			'derniere_modif',
525
-			'optimiser_table',
526
-			'drapeau_edition',
527
-			'creer_preview',
528
-			'taille_preview',
529
-			'creer_htpasswd',
530
-			'creer_htaccess',
531
-			'gd_formats_read',
532
-			'gd_formats',
533
-			'netpbm_formats',
534
-			'formats_graphiques',
535
-			'image_process',
536
-			'plugin_header',
537
-			'plugin'
538
-		);
539
-	// verifier le impt=non
540
-	sql_updateq('spip_meta', array('impt' => 'non'), sql_in('nom', $meta_serveur));
541
-
542
-	foreach ($liste_meta as $nom => $valeur) {
543
-		if (empty($GLOBALS['meta'][$nom])) {
544
-			ecrire_meta($nom, $valeur);
545
-		}
546
-	}
547
-
548
-	include_spip('inc/rubriques');
549
-	$langues = calculer_langues_utilisees();
550
-	ecrire_meta('langues_utilisees', $langues);
514
+    $meta_serveur =
515
+        array(
516
+            'version_installee',
517
+            'adresse_site',
518
+            'alea_ephemere_ancien',
519
+            'alea_ephemere',
520
+            'alea_ephemere_date',
521
+            'langue_site',
522
+            'langues_proposees',
523
+            'date_calcul_rubriques',
524
+            'derniere_modif',
525
+            'optimiser_table',
526
+            'drapeau_edition',
527
+            'creer_preview',
528
+            'taille_preview',
529
+            'creer_htpasswd',
530
+            'creer_htaccess',
531
+            'gd_formats_read',
532
+            'gd_formats',
533
+            'netpbm_formats',
534
+            'formats_graphiques',
535
+            'image_process',
536
+            'plugin_header',
537
+            'plugin'
538
+        );
539
+    // verifier le impt=non
540
+    sql_updateq('spip_meta', array('impt' => 'non'), sql_in('nom', $meta_serveur));
541
+
542
+    foreach ($liste_meta as $nom => $valeur) {
543
+        if (empty($GLOBALS['meta'][$nom])) {
544
+            ecrire_meta($nom, $valeur);
545
+        }
546
+    }
547
+
548
+    include_spip('inc/rubriques');
549
+    $langues = calculer_langues_utilisees();
550
+    ecrire_meta('langues_utilisees', $langues);
551 551
 }
552 552
 
553 553
 
@@ -569,18 +569,18 @@  discard block
 block discarded – undo
569 569
  */
570 570
 function appliquer_modifs_config($purger_skel = false) {
571 571
 
572
-	foreach (liste_metas() as $i => $v) {
573
-		if (($x = _request($i)) !== null) {
574
-			ecrire_meta($i, $x);
575
-		} elseif (!isset($GLOBALS['meta'][$i])) {
576
-			ecrire_meta($i, $v);
577
-		}
578
-	}
579
-
580
-	if ($purger_skel) {
581
-		include_spip('inc/invalideur');
582
-		purger_repertoire(_DIR_SKELS);
583
-	}
572
+    foreach (liste_metas() as $i => $v) {
573
+        if (($x = _request($i)) !== null) {
574
+            ecrire_meta($i, $x);
575
+        } elseif (!isset($GLOBALS['meta'][$i])) {
576
+            ecrire_meta($i, $v);
577
+        }
578
+    }
579
+
580
+    if ($purger_skel) {
581
+        include_spip('inc/invalideur');
582
+        purger_repertoire(_DIR_SKELS);
583
+    }
584 584
 }
585 585
 
586 586
 /**
@@ -591,21 +591,21 @@  discard block
 block discarded – undo
591 591
  * @return string
592 592
  */
593 593
 function appliquer_adresse_site($adresse_site) {
594
-	if ($adresse_site !== null) {
595
-		if (!strlen($adresse_site)) {
596
-			$GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1;
597
-			$adresse_site = url_de_base();
598
-		}
599
-		$adresse_site = preg_replace(",/?\s*$,", "", $adresse_site);
594
+    if ($adresse_site !== null) {
595
+        if (!strlen($adresse_site)) {
596
+            $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1;
597
+            $adresse_site = url_de_base();
598
+        }
599
+        $adresse_site = preg_replace(",/?\s*$,", "", $adresse_site);
600 600
 
601
-		if (!tester_url_absolue($adresse_site)) {
602
-			$adresse_site = "http://$adresse_site";
603
-		}
601
+        if (!tester_url_absolue($adresse_site)) {
602
+            $adresse_site = "http://$adresse_site";
603
+        }
604 604
 
605
-		$adresse_site = entites_html($adresse_site);
605
+        $adresse_site = entites_html($adresse_site);
606 606
 
607
-		ecrire_meta('adresse_site', $adresse_site);
608
-	}
607
+        ecrire_meta('adresse_site', $adresse_site);
608
+    }
609 609
 
610
-	return $adresse_site;
610
+    return $adresse_site;
611 611
 }
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -384,10 +384,12 @@
 block discarded – undo
384 384
 		$texte = $court;
385 385
 	}
386 386
 
387
-	if (strpos($texte, "\n"))  // la fin est encore la : c'est qu'on n'a pas de texte de suite
387
+	if (strpos($texte, "\n")) {
388
+	    // la fin est encore la : c'est qu'on n'a pas de texte de suite
388 389
 	{
389 390
 		$points = '';
390 391
 	}
392
+	}
391 393
 
392 394
 	// remettre les paragraphes
393 395
 	$texte = preg_replace("/\r+/", "\n\n", $texte);
Please login to merge, or discard this patch.
Indentation   +374 added lines, -374 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('inc/filtres');
23 23
 include_spip('inc/lang');
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function definir_puce() {
41 41
 
42
-	// Attention au sens, qui n'est pas defini de la meme facon dans
43
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
-	// celle du texte) et public (spip_lang est la langue du texte)
45
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
42
+    // Attention au sens, qui n'est pas defini de la meme facon dans
43
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
+    // celle du texte) et public (spip_lang est la langue du texte)
45
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
-	if ($dir == 'rtl') {
49
-		$p .= '_rtl';
50
-	}
47
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
+    if ($dir == 'rtl') {
49
+        $p .= '_rtl';
50
+    }
51 51
 
52
-	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54
-	}
52
+    if (!isset($GLOBALS[$p])) {
53
+        $GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54
+    }
55 55
 
56
-	return $GLOBALS[$p];
56
+    return $GLOBALS[$p];
57 57
 }
58 58
 
59 59
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 // dont on souhaite qu'ils provoquent un saut de paragraphe
62 62
 
63 63
 if (!defined('_BALISES_BLOCS')) {
64
-	define('_BALISES_BLOCS',
65
-	'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
66
-	);
64
+    define('_BALISES_BLOCS',
65
+    'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
66
+    );
67 67
 }
68 68
 
69 69
 if (!defined('_BALISES_BLOCS_REGEXP')) {
70
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
70
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71 71
 }
72 72
 
73 73
 //
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
 // echappe est un div ou un span
80 80
 // https://code.spip.net/@code_echappement
81 81
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82
-	if (!strlen($rempl)) {
83
-		return '';
84
-	}
85
-
86
-	// Tester si on echappe en span ou en div
87
-	if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
-	}
90
-
91
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
-	$taille = 30000;
93
-	$return = "";
94
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
-		// Convertir en base64 et cacher dans un attribut
96
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
97
-		$base64 = base64_encode(substr($rempl, $i, $taille));
98
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
-	}
100
-
101
-	return $return;
82
+    if (!strlen($rempl)) {
83
+        return '';
84
+    }
85
+
86
+    // Tester si on echappe en span ou en div
87
+    if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
+    }
90
+
91
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
+    $taille = 30000;
93
+    $return = "";
94
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
+        // Convertir en base64 et cacher dans un attribut
96
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
97
+        $base64 = base64_encode(substr($rempl, $i, $taille));
98
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
+    }
100
+
101
+    return $return;
102 102
 
103 103
 }
104 104
 
@@ -106,84 +106,84 @@  discard block
 block discarded – undo
106 106
 // Echapper les <html>...</ html>
107 107
 // https://code.spip.net/@traiter_echap_html_dist
108 108
 function traiter_echap_html_dist($regs) {
109
-	return $regs[3];
109
+    return $regs[3];
110 110
 }
111 111
 
112 112
 // Echapper les <pre>...</ pre>
113 113
 function traiter_echap_pre_dist($regs) {
114
-	// echapper les <code> dans <pre>
115
-	$pre = $regs[3];
116
-
117
-	// echapper les < dans <code>
118
-	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
119
-	if (strpos($pre, "<") !== false
120
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)){
121
-
122
-		foreach ($matches as $m){
123
-			if ($m[1]==='code'){
124
-				$code = "<code" . $m[2] . ">" . spip_htmlspecialchars($m[3]) . "</code>";
125
-				$pre = str_replace($m[0], $code, $pre);
126
-			}
127
-		}
128
-	}
129
-	return "<pre>$pre</pre>";
114
+    // echapper les <code> dans <pre>
115
+    $pre = $regs[3];
116
+
117
+    // echapper les < dans <code>
118
+    // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
119
+    if (strpos($pre, "<") !== false
120
+        and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)){
121
+
122
+        foreach ($matches as $m){
123
+            if ($m[1]==='code'){
124
+                $code = "<code" . $m[2] . ">" . spip_htmlspecialchars($m[3]) . "</code>";
125
+                $pre = str_replace($m[0], $code, $pre);
126
+            }
127
+        }
128
+    }
129
+    return "<pre>$pre</pre>";
130 130
 }
131 131
 
132 132
 // Echapper les <code>...</ code>
133 133
 // https://code.spip.net/@traiter_echap_code_dist
134 134
 function traiter_echap_code_dist($regs) {
135
-	list(, , $att, $corps) = $regs;
136
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
137
-
138
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
139
-	if (is_int(strpos($echap, "\n"))) {
140
-		// supprimer les sauts de ligne debut/fin
141
-		// (mais pas les espaces => ascii art).
142
-		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap);
143
-		$echap = nl2br($echap);
144
-		$echap = "<div style='text-align: left;' "
145
-			. "class='spip_code' dir='ltr'><code$att>"
146
-			. $echap . "</code></div>";
147
-	} else {
148
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
149
-	}
150
-
151
-	$echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
152
-	$echap = str_replace("  ", " &nbsp;", $echap);
153
-
154
-	return $echap;
135
+    list(, , $att, $corps) = $regs;
136
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
137
+
138
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
139
+    if (is_int(strpos($echap, "\n"))) {
140
+        // supprimer les sauts de ligne debut/fin
141
+        // (mais pas les espaces => ascii art).
142
+        $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap);
143
+        $echap = nl2br($echap);
144
+        $echap = "<div style='text-align: left;' "
145
+            . "class='spip_code' dir='ltr'><code$att>"
146
+            . $echap . "</code></div>";
147
+    } else {
148
+        $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
149
+    }
150
+
151
+    $echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
152
+    $echap = str_replace("  ", " &nbsp;", $echap);
153
+
154
+    return $echap;
155 155
 }
156 156
 
157 157
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
158 158
 // https://code.spip.net/@traiter_echap_cadre_dist
159 159
 function traiter_echap_cadre_dist($regs) {
160
-	$echap = trim(entites_html($regs[3]));
161
-	// compter les lignes un peu plus finement qu'avec les \n
162
-	$lignes = explode("\n", trim($echap));
163
-	$n = 0;
164
-	foreach ($lignes as $l) {
165
-		$n += floor(strlen($l) / 60) + 1;
166
-	}
167
-	$n = max($n, 2);
168
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
169
-
170
-	return $echap;
160
+    $echap = trim(entites_html($regs[3]));
161
+    // compter les lignes un peu plus finement qu'avec les \n
162
+    $lignes = explode("\n", trim($echap));
163
+    $n = 0;
164
+    foreach ($lignes as $l) {
165
+        $n += floor(strlen($l) / 60) + 1;
166
+    }
167
+    $n = max($n, 2);
168
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
169
+
170
+    return $echap;
171 171
 }
172 172
 
173 173
 // https://code.spip.net/@traiter_echap_frame_dist
174 174
 function traiter_echap_frame_dist($regs) {
175
-	return traiter_echap_cadre_dist($regs);
175
+    return traiter_echap_cadre_dist($regs);
176 176
 }
177 177
 
178 178
 // https://code.spip.net/@traiter_echap_script_dist
179 179
 function traiter_echap_script_dist($regs) {
180
-	// rendre joli (et inactif) si c'est un script language=php
181
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
182
-		return highlight_string($regs[0], true);
183
-	}
180
+    // rendre joli (et inactif) si c'est un script language=php
181
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
182
+        return highlight_string($regs[0], true);
183
+    }
184 184
 
185
-	// Cas normal : le script passe tel quel
186
-	return $regs[0];
185
+    // Cas normal : le script passe tel quel
186
+    return $regs[0];
187 187
 }
188 188
 
189 189
 define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\s[^>]*)?>(.*)</\1>,UimsS');
@@ -203,69 +203,69 @@  discard block
 block discarded – undo
203 203
  * @return string|string[]
204 204
  */
205 205
 function echappe_html(
206
-	$letexte,
207
-	$source = '',
208
-	$no_transform = false,
209
-	$preg = '',
210
-	$callback_prefix = ''
206
+    $letexte,
207
+    $source = '',
208
+    $no_transform = false,
209
+    $preg = '',
210
+    $callback_prefix = ''
211 211
 ) {
212
-	if (!is_string($letexte) or !strlen($letexte)) {
213
-		return $letexte;
214
-	}
215
-
216
-	// si le texte recu est long PCRE risque d'exploser, on
217
-	// fait donc un mic-mac pour augmenter pcre.backtrack_limit
218
-	if (($len = strlen($letexte)) > 100000) {
219
-		if (!$old = @ini_get('pcre.backtrack_limit')) {
220
-			$old = 100000;
221
-		}
222
-		if ($len > $old) {
223
-			$a = @ini_set('pcre.backtrack_limit', $len);
224
-			spip_log("ini_set pcre.backtrack_limit=$len ($old)");
225
-		}
226
-	}
227
-
228
-	if (($preg or strpos($letexte, "<") !== false)
229
-		and preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
230
-	) {
231
-		foreach ($matches as $regs) {
232
-			// echappements tels quels ?
233
-			if ($no_transform) {
234
-				$echap = $regs[0];
235
-			} // sinon les traiter selon le cas
236
-			else {
237
-				if (function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
238
-				  or function_exists($f = $f . '_dist')) {
239
-					$echap = $f($regs);
240
-				}
241
-			}
242
-
243
-			$p = strpos($letexte, $regs[0]);
244
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
245
-		}
246
-	}
247
-
248
-	if ($no_transform) {
249
-		return $letexte;
250
-	}
251
-
252
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
253
-	// seulement si on a echappe les <script>
254
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
255
-	// dans une callback autonommee
256
-	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
257
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
258
-				$letexte, $matches, PREG_SET_ORDER)
259
-		) {
260
-			foreach ($matches as $regs) {
261
-				$letexte = str_replace($regs[0],
262
-					code_echappement(highlight_string($regs[0], true), $source),
263
-					$letexte);
264
-			}
265
-		}
266
-	}
267
-
268
-	return $letexte;
212
+    if (!is_string($letexte) or !strlen($letexte)) {
213
+        return $letexte;
214
+    }
215
+
216
+    // si le texte recu est long PCRE risque d'exploser, on
217
+    // fait donc un mic-mac pour augmenter pcre.backtrack_limit
218
+    if (($len = strlen($letexte)) > 100000) {
219
+        if (!$old = @ini_get('pcre.backtrack_limit')) {
220
+            $old = 100000;
221
+        }
222
+        if ($len > $old) {
223
+            $a = @ini_set('pcre.backtrack_limit', $len);
224
+            spip_log("ini_set pcre.backtrack_limit=$len ($old)");
225
+        }
226
+    }
227
+
228
+    if (($preg or strpos($letexte, "<") !== false)
229
+        and preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
230
+    ) {
231
+        foreach ($matches as $regs) {
232
+            // echappements tels quels ?
233
+            if ($no_transform) {
234
+                $echap = $regs[0];
235
+            } // sinon les traiter selon le cas
236
+            else {
237
+                if (function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
238
+                  or function_exists($f = $f . '_dist')) {
239
+                    $echap = $f($regs);
240
+                }
241
+            }
242
+
243
+            $p = strpos($letexte, $regs[0]);
244
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
245
+        }
246
+    }
247
+
248
+    if ($no_transform) {
249
+        return $letexte;
250
+    }
251
+
252
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
253
+    // seulement si on a echappe les <script>
254
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
255
+    // dans une callback autonommee
256
+    if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
257
+        if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
258
+                $letexte, $matches, PREG_SET_ORDER)
259
+        ) {
260
+            foreach ($matches as $regs) {
261
+                $letexte = str_replace($regs[0],
262
+                    code_echappement(highlight_string($regs[0], true), $source),
263
+                    $letexte);
264
+            }
265
+        }
266
+    }
267
+
268
+    return $letexte;
269 269
 }
270 270
 
271 271
 //
@@ -274,52 +274,52 @@  discard block
 block discarded – undo
274 274
 // par propre() : exemple dans multi et dans typo()
275 275
 // https://code.spip.net/@echappe_retour
276 276
 function echappe_retour($letexte, $source = '', $filtre = "") {
277
-	if (strpos($letexte, "base64$source")) {
278
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
279
-		$max_prof = 5;
280
-		while (strpos($letexte, "<") !== false
281
-			and
282
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
283
-				$letexte, $regs, PREG_SET_ORDER)
284
-			and $max_prof--) {
285
-			foreach ($regs as $reg) {
286
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
287
-				// recherche d'attributs supplementaires
288
-				$at = array();
289
-				foreach (array('lang', 'dir') as $attr) {
290
-					if ($a = extraire_attribut($reg[0], $attr)) {
291
-						$at[$attr] = $a;
292
-					}
293
-				}
294
-				if ($at) {
295
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
296
-					foreach ($at as $attr => $a) {
297
-						$rempl = inserer_attribut($rempl, $attr, $a);
298
-					}
299
-				}
300
-				if ($filtre) {
301
-					$rempl = $filtre($rempl);
302
-				}
303
-				$letexte = str_replace($reg[0], $rempl, $letexte);
304
-			}
305
-		}
306
-	}
307
-
308
-	return $letexte;
277
+    if (strpos($letexte, "base64$source")) {
278
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
279
+        $max_prof = 5;
280
+        while (strpos($letexte, "<") !== false
281
+            and
282
+            preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
283
+                $letexte, $regs, PREG_SET_ORDER)
284
+            and $max_prof--) {
285
+            foreach ($regs as $reg) {
286
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
287
+                // recherche d'attributs supplementaires
288
+                $at = array();
289
+                foreach (array('lang', 'dir') as $attr) {
290
+                    if ($a = extraire_attribut($reg[0], $attr)) {
291
+                        $at[$attr] = $a;
292
+                    }
293
+                }
294
+                if ($at) {
295
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
296
+                    foreach ($at as $attr => $a) {
297
+                        $rempl = inserer_attribut($rempl, $attr, $a);
298
+                    }
299
+                }
300
+                if ($filtre) {
301
+                    $rempl = $filtre($rempl);
302
+                }
303
+                $letexte = str_replace($reg[0], $rempl, $letexte);
304
+            }
305
+        }
306
+    }
307
+
308
+    return $letexte;
309 309
 }
310 310
 
311 311
 // Reinserer le javascript de confiance (venant des modeles)
312 312
 
313 313
 // https://code.spip.net/@echappe_retour_modeles
314 314
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
315
-	$letexte = echappe_retour($letexte);
315
+    $letexte = echappe_retour($letexte);
316 316
 
317
-	// Dans les appels directs hors squelette, securiser aussi ici
318
-	if ($interdire_scripts) {
319
-		$letexte = interdire_scripts($letexte);
320
-	}
317
+    // Dans les appels directs hors squelette, securiser aussi ici
318
+    if ($interdire_scripts) {
319
+        $letexte = interdire_scripts($letexte);
320
+    }
321 321
 
322
-	return trim($letexte);
322
+    return trim($letexte);
323 323
 }
324 324
 
325 325
 
@@ -347,130 +347,130 @@  discard block
 block discarded – undo
347 347
  *     Texte coupé
348 348
  **/
349 349
 function couper($texte, $taille = 50, $suite = null) {
350
-	if (!($length = strlen($texte)) or $taille <= 0) {
351
-		return '';
352
-	}
353
-	$offset = 400 + 2 * $taille;
354
-	while ($offset < $length
355
-		and strlen(preg_replace(",<(!--|\w|/)[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
356
-		$offset = 2 * $offset;
357
-	}
358
-	if ($offset < $length
359
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
360
-	) {
361
-		$p_tag_fermant = strpos($texte, '>', $offset);
362
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
363
-			$offset = $p_tag_fermant + 1;
364
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
365
-	}
366
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
367
-
368
-	if (!function_exists('nettoyer_raccourcis_typo')) {
369
-		include_spip('inc/lien');
370
-	}
371
-	$texte = nettoyer_raccourcis_typo($texte);
372
-
373
-	// balises de sauts de ligne et paragraphe
374
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
375
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
376
-
377
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
378
-	$texte = str_replace("\n\n", "\r", $texte);
379
-
380
-	// supprimer les tags
381
-	$texte = supprimer_tags($texte);
382
-	$texte = trim(str_replace("\n", " ", $texte));
383
-	$texte .= "\n";  // marquer la fin
384
-
385
-	// corriger la longueur de coupe
386
-	// en fonction de la presence de caracteres utf
387
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
388
-		$long = charset2unicode($texte);
389
-		$long = spip_substr($long, 0, max($taille, 1));
390
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
391
-		$taille += $nbcharutf;
392
-	}
393
-
394
-
395
-	// couper au mot precedent
396
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
397
-	$u = $GLOBALS['meta']['pcre_u'];
398
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
399
-	if (is_null($suite)) {
400
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
401
-	}
402
-	$points = $suite;
403
-
404
-	// trop court ? ne pas faire de (...)
405
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
406
-		$points = '';
407
-		$long = spip_substr($texte, 0, $taille);
408
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
409
-		// encore trop court ? couper au caractere
410
-		if (spip_strlen($texte) < 0.75 * $taille) {
411
-			$texte = $long;
412
-		}
413
-	} else {
414
-		$texte = $court;
415
-	}
416
-
417
-	if (strpos($texte, "\n"))  // la fin est encore la : c'est qu'on n'a pas de texte de suite
418
-	{
419
-		$points = '';
420
-	}
421
-
422
-	// remettre les paragraphes
423
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
424
-
425
-	// supprimer l'eventuelle entite finale mal coupee
426
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
427
-
428
-	return quote_amp(trim($texte)) . $points;
350
+    if (!($length = strlen($texte)) or $taille <= 0) {
351
+        return '';
352
+    }
353
+    $offset = 400 + 2 * $taille;
354
+    while ($offset < $length
355
+        and strlen(preg_replace(",<(!--|\w|/)[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille) {
356
+        $offset = 2 * $offset;
357
+    }
358
+    if ($offset < $length
359
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
360
+    ) {
361
+        $p_tag_fermant = strpos($texte, '>', $offset);
362
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
363
+            $offset = $p_tag_fermant + 1;
364
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
365
+    }
366
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
367
+
368
+    if (!function_exists('nettoyer_raccourcis_typo')) {
369
+        include_spip('inc/lien');
370
+    }
371
+    $texte = nettoyer_raccourcis_typo($texte);
372
+
373
+    // balises de sauts de ligne et paragraphe
374
+    $texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
375
+    $texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
376
+
377
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
378
+    $texte = str_replace("\n\n", "\r", $texte);
379
+
380
+    // supprimer les tags
381
+    $texte = supprimer_tags($texte);
382
+    $texte = trim(str_replace("\n", " ", $texte));
383
+    $texte .= "\n";  // marquer la fin
384
+
385
+    // corriger la longueur de coupe
386
+    // en fonction de la presence de caracteres utf
387
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
388
+        $long = charset2unicode($texte);
389
+        $long = spip_substr($long, 0, max($taille, 1));
390
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
391
+        $taille += $nbcharutf;
392
+    }
393
+
394
+
395
+    // couper au mot precedent
396
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
397
+    $u = $GLOBALS['meta']['pcre_u'];
398
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
399
+    if (is_null($suite)) {
400
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
401
+    }
402
+    $points = $suite;
403
+
404
+    // trop court ? ne pas faire de (...)
405
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
406
+        $points = '';
407
+        $long = spip_substr($texte, 0, $taille);
408
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
409
+        // encore trop court ? couper au caractere
410
+        if (spip_strlen($texte) < 0.75 * $taille) {
411
+            $texte = $long;
412
+        }
413
+    } else {
414
+        $texte = $court;
415
+    }
416
+
417
+    if (strpos($texte, "\n"))  // la fin est encore la : c'est qu'on n'a pas de texte de suite
418
+    {
419
+        $points = '';
420
+    }
421
+
422
+    // remettre les paragraphes
423
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
424
+
425
+    // supprimer l'eventuelle entite finale mal coupee
426
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
427
+
428
+    return quote_amp(trim($texte)) . $points;
429 429
 }
430 430
 
431 431
 
432 432
 // https://code.spip.net/@protege_js_modeles
433 433
 function protege_js_modeles($t) {
434
-	if (isset($GLOBALS['visiteur_session'])) {
435
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
436
-			if (!defined('_PROTEGE_JS_MODELES')) {
437
-				include_spip('inc/acces');
438
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
439
-			}
440
-			foreach ($r as $regs) {
441
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
442
-			}
443
-		}
444
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
445
-			if (!defined('_PROTEGE_PHP_MODELES')) {
446
-				include_spip('inc/acces');
447
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
448
-			}
449
-			foreach ($r as $regs) {
450
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
451
-			}
452
-		}
453
-	}
454
-
455
-	return $t;
434
+    if (isset($GLOBALS['visiteur_session'])) {
435
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
436
+            if (!defined('_PROTEGE_JS_MODELES')) {
437
+                include_spip('inc/acces');
438
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
439
+            }
440
+            foreach ($r as $regs) {
441
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
442
+            }
443
+        }
444
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
445
+            if (!defined('_PROTEGE_PHP_MODELES')) {
446
+                include_spip('inc/acces');
447
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
448
+            }
449
+            foreach ($r as $regs) {
450
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
451
+            }
452
+        }
453
+    }
454
+
455
+    return $t;
456 456
 }
457 457
 
458 458
 
459 459
 function echapper_faux_tags($letexte) {
460
-	if (strpos($letexte, '<') === false) {
461
-		return $letexte;
462
-	}
463
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
464
-
465
-	$letexte = "";
466
-	while (count($textMatches)) {
467
-		// un texte a echapper
468
-		$letexte .= str_replace("<", '&lt;', array_shift($textMatches));
469
-		// un tag html qui a servit a faite le split
470
-		$letexte .= array_shift($textMatches);
471
-	}
472
-
473
-	return $letexte;
460
+    if (strpos($letexte, '<') === false) {
461
+        return $letexte;
462
+    }
463
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
464
+
465
+    $letexte = "";
466
+    while (count($textMatches)) {
467
+        // un texte a echapper
468
+        $letexte .= str_replace("<", '&lt;', array_shift($textMatches));
469
+        // un tag html qui a servit a faite le split
470
+        $letexte .= array_shift($textMatches);
471
+    }
472
+
473
+    return $letexte;
474 474
 }
475 475
 
476 476
 /**
@@ -483,44 +483,44 @@  discard block
 block discarded – undo
483 483
  * @return string
484 484
  */
485 485
 function echapper_html_suspect($texte, $strict=true) {
486
-	static $echapper_html_suspect;
487
-	if (!$texte or !is_string($texte)) {
488
-		return $texte;
489
-	}
490
-
491
-	if (!isset($echapper_html_suspect)) {
492
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
493
-	}
494
-	// si fonction personalisee, on delegue
495
-	if ($echapper_html_suspect) {
496
-		return $echapper_html_suspect($texte, $strict);
497
-	}
498
-
499
-	if (strpos($texte, '<') === false
500
-	  or strpos($texte, '=') === false) {
501
-		return $texte;
502
-	}
503
-
504
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
505
-	// car sinon on declenche sur les modeles ou ressources
506
-	if (!$strict and
507
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
-	  ){
509
-		return $texte;
510
-	}
511
-
512
-	// on teste sur strlen car safehtml supprime le contenu dangereux
513
-	// mais il peut aussi changer des ' en " sur les attributs html,
514
-	// donc un test d'egalite est trop strict
515
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
516
-		$texte = str_replace("<", "&lt;", $texte);
517
-		if (!function_exists('attribut_html')) {
518
-			include_spip('inc/filtres');
519
-		}
520
-		$texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
521
-	}
522
-
523
-	return $texte;
486
+    static $echapper_html_suspect;
487
+    if (!$texte or !is_string($texte)) {
488
+        return $texte;
489
+    }
490
+
491
+    if (!isset($echapper_html_suspect)) {
492
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
493
+    }
494
+    // si fonction personalisee, on delegue
495
+    if ($echapper_html_suspect) {
496
+        return $echapper_html_suspect($texte, $strict);
497
+    }
498
+
499
+    if (strpos($texte, '<') === false
500
+      or strpos($texte, '=') === false) {
501
+        return $texte;
502
+    }
503
+
504
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
505
+    // car sinon on declenche sur les modeles ou ressources
506
+    if (!$strict and
507
+      (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
+        ){
509
+        return $texte;
510
+    }
511
+
512
+    // on teste sur strlen car safehtml supprime le contenu dangereux
513
+    // mais il peut aussi changer des ' en " sur les attributs html,
514
+    // donc un test d'egalite est trop strict
515
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
516
+        $texte = str_replace("<", "&lt;", $texte);
517
+        if (!function_exists('attribut_html')) {
518
+            include_spip('inc/filtres');
519
+        }
520
+        $texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
521
+    }
522
+
523
+    return $texte;
524 524
 }
525 525
 
526 526
 
@@ -541,30 +541,30 @@  discard block
 block discarded – undo
541 541
  *      Texte sécurisé
542 542
  **/
543 543
 function safehtml($t) {
544
-	static $safehtml;
545
-
546
-	if (!$t or !is_string($t)) {
547
-		return $t;
548
-	}
549
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
550
-	if (strpos($t, '<') === false) {
551
-		return str_replace("\x00", '', $t);
552
-	}
553
-
554
-	if (!function_exists('interdire_scripts')) {
555
-		include_spip('inc/texte');
556
-	}
557
-	$t = interdire_scripts($t); // jolifier le php
558
-	$t = echappe_js($t);
559
-
560
-	if (!isset($safehtml)) {
561
-		$safehtml = charger_fonction('safehtml', 'inc', true);
562
-	}
563
-	if ($safehtml) {
564
-		$t = $safehtml($t);
565
-	}
566
-
567
-	return interdire_scripts($t); // interdire le php (2 precautions)
544
+    static $safehtml;
545
+
546
+    if (!$t or !is_string($t)) {
547
+        return $t;
548
+    }
549
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
550
+    if (strpos($t, '<') === false) {
551
+        return str_replace("\x00", '', $t);
552
+    }
553
+
554
+    if (!function_exists('interdire_scripts')) {
555
+        include_spip('inc/texte');
556
+    }
557
+    $t = interdire_scripts($t); // jolifier le php
558
+    $t = echappe_js($t);
559
+
560
+    if (!isset($safehtml)) {
561
+        $safehtml = charger_fonction('safehtml', 'inc', true);
562
+    }
563
+    if ($safehtml) {
564
+        $t = $safehtml($t);
565
+    }
566
+
567
+    return interdire_scripts($t); // interdire le php (2 precautions)
568 568
 }
569 569
 
570 570
 
@@ -586,10 +586,10 @@  discard block
 block discarded – undo
586 586
  *     Texte sans les modèles d'image
587 587
  **/
588 588
 function supprime_img($letexte, $message = null) {
589
-	if ($message === null) {
590
-		$message = '(' . _T('img_indisponible') . ')';
591
-	}
589
+    if ($message === null) {
590
+        $message = '(' . _T('img_indisponible') . ')';
591
+    }
592 592
 
593
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
-		$message, $letexte);
593
+    return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
+        $message, $letexte);
595 595
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	// celle du texte) et public (spip_lang est la langue du texte)
45 45
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
48 48
 	if ($dir == 'rtl') {
49 49
 		$p .= '_rtl';
50 50
 	}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 }
68 68
 
69 69
 if (!defined('_BALISES_BLOCS_REGEXP')) {
70
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
70
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
71 71
 }
72 72
 
73 73
 //
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	// Tester si on echappe en span ou en div
87 87
 	if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
88
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89 89
 	}
90 90
 
91 91
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	// echapper les < dans <code>
118 118
 	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
119 119
 	if (strpos($pre, "<") !== false
120
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)){
120
+		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)) {
121 121
 
122
-		foreach ($matches as $m){
123
-			if ($m[1]==='code'){
124
-				$code = "<code" . $m[2] . ">" . spip_htmlspecialchars($m[3]) . "</code>";
122
+		foreach ($matches as $m) {
123
+			if ($m[1] === 'code') {
124
+				$code = "<code".$m[2].">".spip_htmlspecialchars($m[3])."</code>";
125 125
 				$pre = str_replace($m[0], $code, $pre);
126 126
 			}
127 127
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 // Echapper les <code>...</ code>
133 133
 // https://code.spip.net/@traiter_echap_code_dist
134 134
 function traiter_echap_code_dist($regs) {
135
-	list(, , $att, $corps) = $regs;
135
+	list(,, $att, $corps) = $regs;
136 136
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
137 137
 
138 138
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$echap = nl2br($echap);
144 144
 		$echap = "<div style='text-align: left;' "
145 145
 			. "class='spip_code' dir='ltr'><code$att>"
146
-			. $echap . "</code></div>";
146
+			. $echap."</code></div>";
147 147
 	} else {
148
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
148
+		$echap = "<code$att class='spip_code' dir='ltr'>".$echap."</code>";
149 149
 	}
150 150
 
151 151
 	$echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 				$echap = $regs[0];
235 235
 			} // sinon les traiter selon le cas
236 236
 			else {
237
-				if (function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
238
-				  or function_exists($f = $f . '_dist')) {
237
+				if (function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1]))
238
+				  or function_exists($f = $f.'_dist')) {
239 239
 					$echap = $f($regs);
240 240
 				}
241 241
 			}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	// (derogatoire car on ne peut pas faire passer < ? ... ? >
255 255
 	// dans une callback autonommee
256 256
 	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
257
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
257
+		if (strpos($letexte, "<"."?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
258 258
 				$letexte, $matches, PREG_SET_ORDER)
259 259
 		) {
260 260
 			foreach ($matches as $regs) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$max_prof = 5;
280 280
 		while (strpos($letexte, "<") !== false
281 281
 			and
282
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
282
+			preg_match_all(',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
283 283
 				$letexte, $regs, PREG_SET_ORDER)
284 284
 			and $max_prof--) {
285 285
 			foreach ($regs as $reg) {
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 					}
293 293
 				}
294 294
 				if ($at) {
295
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
295
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
296 296
 					foreach ($at as $attr => $a) {
297 297
 						$rempl = inserer_attribut($rempl, $attr, $a);
298 298
 					}
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	$texte = nettoyer_raccourcis_typo($texte);
372 372
 
373 373
 	// balises de sauts de ligne et paragraphe
374
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
375
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
374
+	$texte = preg_replace("/<p( [^>]*)?".">/", "\r", $texte);
375
+	$texte = preg_replace("/<br( [^>]*)?".">/", "\n", $texte);
376 376
 
377 377
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
378 378
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	// supprimer les tags
381 381
 	$texte = supprimer_tags($texte);
382 382
 	$texte = trim(str_replace("\n", " ", $texte));
383
-	$texte .= "\n";  // marquer la fin
383
+	$texte .= "\n"; // marquer la fin
384 384
 
385 385
 	// corriger la longueur de coupe
386 386
 	// en fonction de la presence de caracteres utf
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	// couper au mot precedent
396 396
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
397 397
 	$u = $GLOBALS['meta']['pcre_u'];
398
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
398
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
399 399
 	if (is_null($suite)) {
400 400
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
401 401
 	}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
406 406
 		$points = '';
407 407
 		$long = spip_substr($texte, 0, $taille);
408
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
408
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
409 409
 		// encore trop court ? couper au caractere
410 410
 		if (spip_strlen($texte) < 0.75 * $taille) {
411 411
 			$texte = $long;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	// supprimer l'eventuelle entite finale mal coupee
426 426
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
427 427
 
428
-	return quote_amp(trim($texte)) . $points;
428
+	return quote_amp(trim($texte)).$points;
429 429
 }
430 430
 
431 431
 
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
439 439
 			}
440 440
 			foreach ($r as $regs) {
441
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
441
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
442 442
 			}
443 443
 		}
444
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
444
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
445 445
 			if (!defined('_PROTEGE_PHP_MODELES')) {
446 446
 				include_spip('inc/acces');
447 447
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
448 448
 			}
449 449
 			foreach ($r as $regs) {
450
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
450
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
451 451
 			}
452 452
 		}
453 453
 	}
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
  * @param bool $strict
483 483
  * @return string
484 484
  */
485
-function echapper_html_suspect($texte, $strict=true) {
485
+function echapper_html_suspect($texte, $strict = true) {
486 486
 	static $echapper_html_suspect;
487 487
 	if (!$texte or !is_string($texte)) {
488 488
 		return $texte;
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
505 505
 	// car sinon on declenche sur les modeles ou ressources
506 506
 	if (!$strict and
507
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
-	  ){
507
+	  (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
+	  ) {
509 509
 		return $texte;
510 510
 	}
511 511
 
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
  **/
588 588
 function supprime_img($letexte, $message = null) {
589 589
 	if ($message === null) {
590
-		$message = '(' . _T('img_indisponible') . ')';
590
+		$message = '('._T('img_indisponible').')';
591 591
 	}
592 592
 
593
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
593
+	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
594 594
 		$message, $letexte);
595 595
 }
Please login to merge, or discard this patch.
ecrire/inc/lien_court.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /*
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
  * http://zoumzamzouilam/truc/chose/machin..."
23 23
  */
24 24
 function inc_lien_court($url) {
25
-	$long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40;
26
-	$coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35;
25
+    $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40;
26
+    $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35;
27 27
 
28
-	if (strlen($url) > $long_url) {
29
-		$url = substr($url, 0, $coupe_url) . '...';
30
-	}
28
+    if (strlen($url) > $long_url) {
29
+        $url = substr($url, 0, $coupe_url) . '...';
30
+    }
31 31
 
32
-	return $url;
32
+    return $url;
33 33
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	$coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35;
27 27
 
28 28
 	if (strlen($url) > $long_url) {
29
-		$url = substr($url, 0, $coupe_url) . '...';
29
+		$url = substr($url, 0, $coupe_url).'...';
30 30
 	}
31 31
 
32 32
 	return $url;
Please login to merge, or discard this patch.
ecrire/inc/log.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -11,103 +11,103 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) {
18
-	static $test_repertoire = array();
19
-	static $compteur = array();
20
-	static $debugverb = ''; // pour ne pas le recalculer au reappel
21
-
22
-	if (is_null($logname) or !is_string($logname)) {
23
-		$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
-	}
25
-	if (!isset($compteur[$logname])) {
26
-		$compteur[$logname] = 0;
27
-	}
28
-	if ($logname != 'maj'
29
-		and defined('_MAX_LOG')
30
-		and (
31
-			$compteur[$logname]++ > _MAX_LOG
32
-			or !$GLOBALS['nombre_de_logs']
33
-			or !$GLOBALS['taille_des_logs']
34
-		)
35
-	) {
36
-		return;
37
-	}
38
-
39
-	$logfile = ($logdir === null ? _DIR_LOG : $logdir)
40
-		. ($logname)
41
-		. ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
42
-
43
-	if (!isset($test_repertoire[$d = dirname($logfile)])) {
44
-		$test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
45
-		$test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
46
-			$d,
47
-			'',
48
-			false,
49
-			true
50
-		) : false));
51
-	}
52
-
53
-	// si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
54
-	if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
55
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
56
-	}
57
-
58
-	$rotate = 0;
59
-	$pid = '(pid ' . @getmypid() . ')';
60
-
61
-	// accepter spip_log( Array )
62
-	if (!is_string($message)) {
63
-		$message = var_export($message, true);
64
-	}
65
-
66
-	if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
67
-		$debug = debug_backtrace();
68
-		$l = $debug[1]['line'];
69
-		$fi = $debug[1]['file'];
70
-		if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
71
-			$fi = substr($fi, strlen(_ROOT_RACINE));
72
-		}
73
-		$fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
74
-		$debugverb = "$fi:L$l:$fu" . '():';
75
-	}
76
-
77
-	$m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
78
-		//distinguer les logs prives et publics dans les grep
79
-		. $debugverb
80
-		. (test_espace_prive() ? ':Pri:' : ':Pub:')
81
-		. preg_replace("/\n*$/", "\n", $message);
82
-
83
-
84
-	if (@is_readable($logfile)
85
-		and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
86
-	) {
87
-		$rotate = $GLOBALS['nombre_de_logs'];
88
-		$m .= "[-- rotate --]\n";
89
-	}
90
-
91
-	$f = @fopen($logfile, 'ab');
92
-	if ($f) {
93
-		fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
94
-		fclose($f);
95
-	}
96
-
97
-	if ($rotate-- > 0
98
-		and function_exists('spip_unlink')
99
-	) {
100
-		spip_unlink($logfile . '.' . $rotate);
101
-		while ($rotate--) {
102
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
103
-		}
104
-	}
105
-
106
-	// Dupliquer les erreurs specifiques dans le log general
107
-	if ($logname !== _FILE_LOG
108
-		and defined('_FILE_LOG')
109
-	) {
110
-		inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
111
-	}
112
-	$debugverb = '';
18
+    static $test_repertoire = array();
19
+    static $compteur = array();
20
+    static $debugverb = ''; // pour ne pas le recalculer au reappel
21
+
22
+    if (is_null($logname) or !is_string($logname)) {
23
+        $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
+    }
25
+    if (!isset($compteur[$logname])) {
26
+        $compteur[$logname] = 0;
27
+    }
28
+    if ($logname != 'maj'
29
+        and defined('_MAX_LOG')
30
+        and (
31
+            $compteur[$logname]++ > _MAX_LOG
32
+            or !$GLOBALS['nombre_de_logs']
33
+            or !$GLOBALS['taille_des_logs']
34
+        )
35
+    ) {
36
+        return;
37
+    }
38
+
39
+    $logfile = ($logdir === null ? _DIR_LOG : $logdir)
40
+        . ($logname)
41
+        . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
42
+
43
+    if (!isset($test_repertoire[$d = dirname($logfile)])) {
44
+        $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
45
+        $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
46
+            $d,
47
+            '',
48
+            false,
49
+            true
50
+        ) : false));
51
+    }
52
+
53
+    // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
54
+    if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
55
+        $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
56
+    }
57
+
58
+    $rotate = 0;
59
+    $pid = '(pid ' . @getmypid() . ')';
60
+
61
+    // accepter spip_log( Array )
62
+    if (!is_string($message)) {
63
+        $message = var_export($message, true);
64
+    }
65
+
66
+    if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
67
+        $debug = debug_backtrace();
68
+        $l = $debug[1]['line'];
69
+        $fi = $debug[1]['file'];
70
+        if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
71
+            $fi = substr($fi, strlen(_ROOT_RACINE));
72
+        }
73
+        $fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
74
+        $debugverb = "$fi:L$l:$fu" . '():';
75
+    }
76
+
77
+    $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
78
+        //distinguer les logs prives et publics dans les grep
79
+        . $debugverb
80
+        . (test_espace_prive() ? ':Pri:' : ':Pub:')
81
+        . preg_replace("/\n*$/", "\n", $message);
82
+
83
+
84
+    if (@is_readable($logfile)
85
+        and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
86
+    ) {
87
+        $rotate = $GLOBALS['nombre_de_logs'];
88
+        $m .= "[-- rotate --]\n";
89
+    }
90
+
91
+    $f = @fopen($logfile, 'ab');
92
+    if ($f) {
93
+        fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
94
+        fclose($f);
95
+    }
96
+
97
+    if ($rotate-- > 0
98
+        and function_exists('spip_unlink')
99
+    ) {
100
+        spip_unlink($logfile . '.' . $rotate);
101
+        while ($rotate--) {
102
+            @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
103
+        }
104
+    }
105
+
106
+    // Dupliquer les erreurs specifiques dans le log general
107
+    if ($logname !== _FILE_LOG
108
+        and defined('_FILE_LOG')
109
+    ) {
110
+        inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
111
+    }
112
+    $debugverb = '';
113 113
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 
53 53
 	// si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
54 54
 	if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
55
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
55
+		$logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log';
56 56
 	}
57 57
 
58 58
 	$rotate = 0;
59
-	$pid = '(pid ' . @getmypid() . ')';
59
+	$pid = '(pid '.@getmypid().')';
60 60
 
61 61
 	// accepter spip_log( Array )
62 62
 	if (!is_string($message)) {
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 			$fi = substr($fi, strlen(_ROOT_RACINE));
72 72
 		}
73 73
 		$fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
74
-		$debugverb = "$fi:L$l:$fu" . '():';
74
+		$debugverb = "$fi:L$l:$fu".'():';
75 75
 	}
76 76
 
77
-	$m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
77
+	$m = date('Y-m-d H:i:s').' '.(isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '').' '.$pid.' '
78 78
 		//distinguer les logs prives et publics dans les grep
79 79
 		. $debugverb
80 80
 		. (test_espace_prive() ? ':Pri:' : ':Pub:')
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	if ($rotate-- > 0
98 98
 		and function_exists('spip_unlink')
99 99
 	) {
100
-		spip_unlink($logfile . '.' . $rotate);
100
+		spip_unlink($logfile.'.'.$rotate);
101 101
 		while ($rotate--) {
102
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
102
+			@rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1));
103 103
 		}
104 104
 	}
105 105
 
Please login to merge, or discard this patch.
ecrire/inc/nfslock.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  **/
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/acces');
@@ -101,93 +101,93 @@  discard block
 block discarded – undo
101 101
  * @return int|bool Timestamp du verrou, false si erreur
102 102
  */
103 103
 function spip_nfslock($fichier, $max_age = 0) {
104
-	$tries = 0;
104
+    $tries = 0;
105 105
 
106
-	if (!$max_age) {
107
-		$max_age = _DEFAULT_LOCKTIME;
108
-	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
106
+    if (!$max_age) {
107
+        $max_age = _DEFAULT_LOCKTIME;
108
+    }
109
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112
-	/*
112
+    /*
113 113
 	 * 1. create a tmp file with a psuedo random file name. we also make
114 114
 	 *    tpath which is a buffer to store the full pathname of the tmp file.
115 115
 	 */
116 116
 
117
-	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
119
-	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
-	if (!$tmpfd) {  /* open failed */
121
-		@fclose($tmpfd);
122
-		spip_unlink($tpath);
117
+    $id = creer_uniqid();
118
+    $tpath = _DIR_TMP . "slock.$id";
119
+    $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
+    if (!$tmpfd) {  /* open failed */
121
+        @fclose($tmpfd);
122
+        spip_unlink($tpath);
123 123
 
124
-		return false; //NFSL_SYSF
125
-	}
124
+        return false; //NFSL_SYSF
125
+    }
126 126
 
127
-	/*
127
+    /*
128 128
 	 * 2. make fullpath, a buffer for the full pathname of the lock file.
129 129
 	 *    then start looping trying to lock it
130 130
 	 */
131 131
 
132
-	while ($tries < 10) {
133
-		/*
132
+    while ($tries < 10) {
133
+        /*
134 134
 		 * 3. link tmp file to lock file.  if it goes, we win and we clean
135 135
 		 *    up and return the st_ctime of the lock file.
136 136
 		 */
137 137
 
138
-		if (link($tpath, $lock_file) == 1) {
139
-			spip_unlink($tpath); /* got it! */
140
-			@fclose($tmpfd);
141
-			if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
-				spip_unlink($lock_file);
138
+        if (link($tpath, $lock_file) == 1) {
139
+            spip_unlink($tpath); /* got it! */
140
+            @fclose($tmpfd);
141
+            if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
+                spip_unlink($lock_file);
143 143
 
144
-				return false; // (NFSL_SYSF);
145
-			}
144
+                return false; // (NFSL_SYSF);
145
+            }
146 146
 
147
-			return ($our_tmp['ctime']);
148
-		}
147
+            return ($our_tmp['ctime']);
148
+        }
149 149
 
150
-		/*
150
+        /*
151 151
 		 * 4. the lock failed.  check for a stale lock file, being mindful
152 152
 		 *    of NFS and the fact the time is set from the NFS server.  we
153 153
 		 *    do a write on the tmp file to update its time to the server's
154 154
 		 *    idea of "now."
155 155
 		 */
156 156
 
157
-		$old_stat = lstat($lock_file);
158
-		if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
-			break;
160
-		} /* something bogus is going on */
157
+        $old_stat = lstat($lock_file);
158
+        if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
+            break;
160
+        } /* something bogus is going on */
161 161
 
162 162
 
163
-		if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
-			spip_unlink($lock_file); /* break the stale lock */
165
-			$tries++;
166
-			/* It is CRITICAL that we sleep after breaking
163
+        if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
+            spip_unlink($lock_file); /* break the stale lock */
165
+            $tries++;
166
+            /* It is CRITICAL that we sleep after breaking
167 167
 			 * the lock. Otherwise, we could race with
168 168
 			 * another process and unlink it's newly-
169 169
 			 * created file.
170 170
 			 */
171
-			sleep(1 + rand(0, 4));
172
-			continue;
173
-		}
171
+            sleep(1 + rand(0, 4));
172
+            continue;
173
+        }
174 174
 
175
-		/*
175
+        /*
176 176
 		 * 5. try again
177 177
 		 */
178 178
 
179
-		$tries++;
180
-		sleep(1 + rand(0, 4));
181
-	}
179
+        $tries++;
180
+        sleep(1 + rand(0, 4));
181
+    }
182 182
 
183
-	/*
183
+    /*
184 184
 	 * 6. give up, failure.
185 185
 	 */
186 186
 
187
-	spip_unlink($tpath);
188
-	@fclose($tmpfd);
187
+    spip_unlink($tpath);
188
+    @fclose($tmpfd);
189 189
 
190
-	return false; //(NFSL_LOCKED);
190
+    return false; //(NFSL_LOCKED);
191 191
 }
192 192
 
193 193
 /**
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
  * return bool true si déverrouillé, false sinon
232 232
  */
233 233
 function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) {
234
-	$id = creer_uniqid();
235
-	if (!$max_age) {
236
-		$max_age = _DEFAULT_LOCKTIME;
237
-	}
234
+    $id = creer_uniqid();
235
+    if (!$max_age) {
236
+        $max_age = _DEFAULT_LOCKTIME;
237
+    }
238 238
 
239
-	/*
239
+    /*
240 240
 	 * 1. Build a temp file and stat that to get an idea of what the server
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
245
-	$tmpfd = @fopen($tpath, 'w');
246
-	if ((!$tmpfd)
247
-		or (@fputs($tmpfd, 'zz', 2) != 2)
248
-		or !($our_tmp = fstat($tmpfd))
249
-	) {
250
-		/* The open failed, or we can't write the file, or we can't stat it */
251
-		@fclose($tmpfd);
252
-		spip_unlink($tpath);
244
+    $tpath = _DIR_TMP . "stime.$id";
245
+    $tmpfd = @fopen($tpath, 'w');
246
+    if ((!$tmpfd)
247
+        or (@fputs($tmpfd, 'zz', 2) != 2)
248
+        or !($our_tmp = fstat($tmpfd))
249
+    ) {
250
+        /* The open failed, or we can't write the file, or we can't stat it */
251
+        @fclose($tmpfd);
252
+        spip_unlink($tpath);
253 253
 
254
-		return false; //(NFSL_SYSF);
255
-	}
254
+        return false; //(NFSL_SYSF);
255
+    }
256 256
 
257
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
258
-	spip_unlink($tpath);
257
+    @fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
258
+    spip_unlink($tpath);
259 259
 
260
-	/*
260
+    /*
261 261
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
262 262
 	 */
263 263
 
264
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
264
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
265 265
 
266
-	/*
266
+    /*
267 267
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
268 268
 	 *    lock has expired, sleep the usual random interval before returning.
269 269
 	 *    If we didn't sleep, there could be a race if the caller immediately
270 270
 	 *    tries to relock the file.
271 271
 	 */
272 272
 
273
-	if (($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
274
-		&& ($old_stat['ctime'] == $birth)
275
-	) {  /* hasn't been modified since birth */
276
-		if (!$test) {
277
-			spip_unlink($lock_file);
278
-		}      /* so the lock is ours to remove */
279
-		if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
280
-			if (!$test) {
281
-				return false;
282
-			} //(NFSL_LOST);
283
-			sleep(1 + (random(0, 4)));    /* so sleep a bit */
284
-		}
285
-
286
-		return true;//(NFSL_OK);			/* success */
287
-	}
288
-
289
-	/*
273
+    if (($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
274
+        && ($old_stat['ctime'] == $birth)
275
+    ) {  /* hasn't been modified since birth */
276
+        if (!$test) {
277
+            spip_unlink($lock_file);
278
+        }      /* so the lock is ours to remove */
279
+        if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
280
+            if (!$test) {
281
+                return false;
282
+            } //(NFSL_LOST);
283
+            sleep(1 + (random(0, 4)));    /* so sleep a bit */
284
+        }
285
+
286
+        return true;//(NFSL_OK);			/* success */
287
+    }
288
+
289
+    /*
290 290
 	 * 4. Either ctime has been modified, or the entire lock file is missing.
291 291
 	 *    If the lock should still be ours, based on the ctime of the temp
292 292
 	 *    file, return with NFSL_STOLEN. If not, then our lock is expired and
293 293
 	 *    someone else has grabbed the file, so return NFSL_LOST.
294 294
 	 */
295 295
 
296
-	if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
297
-		return false;
298
-	} //(NFSL_STOLEN);
296
+    if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
297
+        return false;
298
+    } //(NFSL_STOLEN);
299 299
 
300
-	return false; //(NFSL_LOST);	/* The lock must have expired first. */
300
+    return false; //(NFSL_LOST);	/* The lock must have expired first. */
301 301
 }
302 302
 
303 303
 
@@ -321,5 +321,5 @@  discard block
 block discarded – undo
321 321
  * return bool true si déverrouillé, false sinon
322 322
  */
323 323
 function spip_nfslock_test($fichier, $birth, $max_age = 0) {
324
-	return spip_nfsunlock($fichier, $birth, $max_age, true);
324
+    return spip_nfsunlock($fichier, $birth, $max_age, true);
325 325
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	if (!$max_age) {
107 107
 		$max_age = _DEFAULT_LOCKTIME;
108 108
 	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
109
+	$lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112 112
 	/*
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 
117 117
 	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
118
+	$tpath = _DIR_TMP."slock.$id";
119 119
 	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120 120
 	if (!$tmpfd) {  /* open failed */
121 121
 		@fclose($tmpfd);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
244
+	$tpath = _DIR_TMP."stime.$id";
245 245
 	$tmpfd = @fopen($tpath, 'w');
246 246
 	if ((!$tmpfd)
247 247
 		or (@fputs($tmpfd, 'zz', 2) != 2)
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 		return false; //(NFSL_SYSF);
255 255
 	}
256 256
 
257
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
257
+	@fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */
258 258
 	spip_unlink($tpath);
259 259
 
260 260
 	/*
261 261
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
262 262
 	 */
263 263
 
264
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
264
+	$lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8);
265 265
 
266 266
 	/*
267 267
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 			if (!$test) {
281 281
 				return false;
282 282
 			} //(NFSL_LOST);
283
-			sleep(1 + (random(0, 4)));    /* so sleep a bit */
283
+			sleep(1 + (random(0, 4))); /* so sleep a bit */
284 284
 		}
285 285
 
286
-		return true;//(NFSL_OK);			/* success */
286
+		return true; //(NFSL_OK);			/* success */
287 287
 	}
288 288
 
289 289
 	/*
Please login to merge, or discard this patch.
ecrire/inc/roles.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 if (!defined('_ECRIRE_INC_VERSION')) {
31
-	return;
31
+    return;
32 32
 }
33 33
 
34 34
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
  *     array : description des roles applicables dans 3 index : colonne, titres, roles
49 49
  **/
50 50
 function roles_presents($objet, $objet_destination = '') {
51
-	$desc = lister_tables_objets_sql(table_objet_sql($objet));
52
-
53
-	// pas de liste de roles, on sort
54
-	if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
-		return false;
56
-	}
57
-
58
-	// on vérifie que la table de liaison existe
59
-	include_spip('action/editer_liens');
60
-	if (!$lien = objet_associable($objet)) {
61
-		return false;
62
-	}
63
-
64
-	// on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
-	$colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
-	$trouver_table = charger_fonction('trouver_table', 'base');
67
-	list(, $table_lien) = $lien;
68
-	$desc_lien = $trouver_table($table_lien);
69
-	if (!isset($desc_lien['field'][$colonne])) {
70
-		return false;
71
-	}
72
-
73
-	// sur quoi peuvent s'appliquer nos rôles
74
-	if (!$application = $desc['roles_objets']) {
75
-		return false;
76
-	}
77
-
78
-	// destination presente, on restreint si possible
79
-	if ($objet_destination) {
80
-		$objet_destination = table_objet($objet_destination);
81
-
82
-		// pour l'objet
83
-		if (isset($application[$objet_destination])) {
84
-			$application = $application[$objet_destination];
85
-			// sinon pour tous les objets
86
-		} elseif (isset($application['*'])) {
87
-			$application = $application['*'];
88
-		} // sinon tant pis
89
-		else {
90
-			return false;
91
-		}
92
-	}
93
-
94
-	// tout est ok
95
-	return array(
96
-		'titres' => $titres,
97
-		'roles' => $application,
98
-		'colonne' => $colonne
99
-	);
51
+    $desc = lister_tables_objets_sql(table_objet_sql($objet));
52
+
53
+    // pas de liste de roles, on sort
54
+    if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
+        return false;
56
+    }
57
+
58
+    // on vérifie que la table de liaison existe
59
+    include_spip('action/editer_liens');
60
+    if (!$lien = objet_associable($objet)) {
61
+        return false;
62
+    }
63
+
64
+    // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
+    $colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
+    $trouver_table = charger_fonction('trouver_table', 'base');
67
+    list(, $table_lien) = $lien;
68
+    $desc_lien = $trouver_table($table_lien);
69
+    if (!isset($desc_lien['field'][$colonne])) {
70
+        return false;
71
+    }
72
+
73
+    // sur quoi peuvent s'appliquer nos rôles
74
+    if (!$application = $desc['roles_objets']) {
75
+        return false;
76
+    }
77
+
78
+    // destination presente, on restreint si possible
79
+    if ($objet_destination) {
80
+        $objet_destination = table_objet($objet_destination);
81
+
82
+        // pour l'objet
83
+        if (isset($application[$objet_destination])) {
84
+            $application = $application[$objet_destination];
85
+            // sinon pour tous les objets
86
+        } elseif (isset($application['*'])) {
87
+            $application = $application['*'];
88
+        } // sinon tant pis
89
+        else {
90
+            return false;
91
+        }
92
+    }
93
+
94
+    // tout est ok
95
+    return array(
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,23 +136,23 @@  discard block
 block discarded – undo
136 136
  *     Liste ('', '', array()) sinon.
137 137
  **/
138 138
 function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = array()) {
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 = array();
143
-	if ($roles = roles_presents($objet, $objet_destination)) {
144
-		$colonne_role = $roles['colonne'];
145
-		// qu'il n'est pas défini
146
-		if (!isset($qualif[$colonne_role])
147
-			or !($role = $qualif[$colonne_role])
148
-		) {
149
-			$role = $roles['roles']['defaut'];
150
-		}
151
-		// where
152
-		$cond = array("$colonne_role=" . sql_quote($role));
153
-	}
154
-
155
-	return array($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 = array();
143
+    if ($roles = roles_presents($objet, $objet_destination)) {
144
+        $colonne_role = $roles['colonne'];
145
+        // qu'il n'est pas défini
146
+        if (!isset($qualif[$colonne_role])
147
+            or !($role = $qualif[$colonne_role])
148
+        ) {
149
+            $role = $roles['roles']['defaut'];
150
+        }
151
+        // where
152
+        $cond = array("$colonne_role=" . sql_quote($role));
153
+    }
154
+
155
+    return array($role, $colonne_role, $cond);
156 156
 }
157 157
 
158 158
 /**
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
  *     Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé)
175 175
  **/
176 176
 function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) {
177
-	// role par défaut, colonne
178
-	list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
177
+    // role par défaut, colonne
178
+    list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
179 179
 
180
-	// chercher d'eventuels rôles transmis
181
-	$role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
182
-	unset($cond['role']); // cette condition est particuliere...
180
+    // chercher d'eventuels rôles transmis
181
+    $role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
182
+    unset($cond['role']); // cette condition est particuliere...
183 183
 
184
-	if ($colonne_role) {
185
-		// on ajoute la condition du role aux autres conditions.
186
-		if ($role != '*') {
187
-			$cond[] = "$colonne_role=" . sql_quote($role);
188
-		}
189
-	}
184
+    if ($colonne_role) {
185
+        // on ajoute la condition du role aux autres conditions.
186
+        if ($role != '*') {
187
+            $cond[] = "$colonne_role=" . sql_quote($role);
188
+        }
189
+    }
190 190
 
191
-	return array($cond, $colonne_role, $role);
191
+    return array($cond, $colonne_role, $role);
192 192
 }
193 193
 
194 194
 /**
@@ -210,28 +210,28 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function roles_complets($objet_source, $objet, $id_objet, $objet_lien) {
212 212
 
213
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
214
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
215
-	if ($presents === false) {
216
-		return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
217
-	}
218
-
219
-	// types de roles possibles
220
-	$roles_possibles = $presents['roles']['roles']['choix'];
221
-	// couples id / roles
222
-	$ids = $presents['ids'];
223
-
224
-	// pour chaque groupe, on fait le diff entre tous les roles possibles
225
-	// et les roles attribués à l'élément : s'il en reste, c'est que l'élément
226
-	// n'est pas complet
227
-	$complets = array();
228
-	foreach ($ids as $id => $roles_presents) {
229
-		if (!array_diff($roles_possibles, $roles_presents)) {
230
-			$complets[] = $id;
231
-		}
232
-	}
233
-
234
-	return $complets;
213
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
214
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
215
+    if ($presents === false) {
216
+        return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
217
+    }
218
+
219
+    // types de roles possibles
220
+    $roles_possibles = $presents['roles']['roles']['choix'];
221
+    // couples id / roles
222
+    $ids = $presents['ids'];
223
+
224
+    // pour chaque groupe, on fait le diff entre tous les roles possibles
225
+    // et les roles attribués à l'élément : s'il en reste, c'est que l'élément
226
+    // n'est pas complet
227
+    $complets = array();
228
+    foreach ($ids as $id => $roles_presents) {
229
+        if (!array_diff($roles_possibles, $roles_presents)) {
230
+            $complets[] = $id;
231
+        }
232
+    }
233
+
234
+    return $complets;
235 235
 }
236 236
 
237 237
 
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) {
250 250
 
251
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
252
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
253
-	if ($presents === false) {
254
-		return array();
255
-	}
251
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
252
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
253
+    if ($presents === false) {
254
+        return array();
255
+    }
256 256
 
257
-	if (!isset($presents['ids'][$id_objet_source])) {
258
-		return array();
259
-	}
257
+    if (!isset($presents['ids'][$id_objet_source])) {
258
+        return array();
259
+    }
260 260
 
261
-	return $presents['ids'][$id_objet_source];
261
+    return $presents['ids'][$id_objet_source];
262 262
 }
263 263
 
264 264
 
@@ -286,47 +286,47 @@  discard block
 block discarded – undo
286 286
  *     - False si pas de role déclarés
287 287
  */
288 288
 function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) {
289
-	static $done = array();
290
-
291
-	// stocker le résultat
292
-	$hash = "$objet_source-$objet-$id_objet-$objet_lien";
293
-	if (isset($done[$hash])) {
294
-		return $done[$hash];
295
-	}
296
-
297
-	// pas de roles sur ces objets, on sort
298
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
299
-	if (!$roles) {
300
-		return $done[$hash] = false;
301
-	}
302
-
303
-	// inspiré de lister_objets_lies()
304
-	if ($objet_lien == $objet) {
305
-		$res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
306
-	} else {
307
-		$res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
308
-	}
309
-
310
-	// types de roles possibles
311
-	$roles_possibles = $roles['roles']['choix'];
312
-	// colonne du role
313
-	$colonne = $roles['colonne'];
314
-
315
-	// on recupere par id, et role existant
316
-	$ids = array();
317
-	while ($row = array_shift($res)) {
318
-		$id = $row[$objet_source];
319
-		if (!isset($ids[$id])) {
320
-			$ids[$id] = array();
321
-		}
322
-		// tableau des roles présents
323
-		$ids[$id][] = $row[$colonne];
324
-	}
325
-
326
-	return $done[$hash] = array(
327
-		'roles' => $roles,
328
-		'ids' => $ids
329
-	);
289
+    static $done = array();
290
+
291
+    // stocker le résultat
292
+    $hash = "$objet_source-$objet-$id_objet-$objet_lien";
293
+    if (isset($done[$hash])) {
294
+        return $done[$hash];
295
+    }
296
+
297
+    // pas de roles sur ces objets, on sort
298
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
299
+    if (!$roles) {
300
+        return $done[$hash] = false;
301
+    }
302
+
303
+    // inspiré de lister_objets_lies()
304
+    if ($objet_lien == $objet) {
305
+        $res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
306
+    } else {
307
+        $res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
308
+    }
309
+
310
+    // types de roles possibles
311
+    $roles_possibles = $roles['roles']['choix'];
312
+    // colonne du role
313
+    $colonne = $roles['colonne'];
314
+
315
+    // on recupere par id, et role existant
316
+    $ids = array();
317
+    while ($row = array_shift($res)) {
318
+        $id = $row[$objet_source];
319
+        if (!isset($ids[$id])) {
320
+            $ids[$id] = array();
321
+        }
322
+        // tableau des roles présents
323
+        $ids[$id][] = $row[$colonne];
324
+    }
325
+
326
+    return $done[$hash] = array(
327
+        'roles' => $roles,
328
+        'ids' => $ids
329
+    );
330 330
 }
331 331
 
332 332
 
@@ -344,33 +344,33 @@  discard block
 block discarded – undo
344 344
  *     - false si pas de role déclarés
345 345
  */
346 346
 function roles_connus_en_base($objet_source, $objet, $objet_lien) {
347
-	static $done = array();
348
-
349
-	// stocker le résultat
350
-	$hash = "$objet_source-$objet-$objet_lien";
351
-	if (isset($done[$hash])) {
352
-		return $done[$hash];
353
-	}
354
-
355
-	if (!$lien = objet_associable($objet_lien)) {
356
-		return $done[$hash] = false;
357
-	}
358
-
359
-	// pas de roles sur ces objets, on sort
360
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
361
-	if (!$roles) {
362
-		return $done[$hash] = false;
363
-	}
364
-
365
-	list($primary, $l) = $lien;
366
-	$colone_role = $roles['colonne'];
367
-
368
-	$all = sql_allfetsel(
369
-		"DISTINCT $colone_role",
370
-		$l,
371
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
-	);
373
-	$done[$hash] = array_map('reset', $all);
374
-
375
-	return $done[$hash];
347
+    static $done = array();
348
+
349
+    // stocker le résultat
350
+    $hash = "$objet_source-$objet-$objet_lien";
351
+    if (isset($done[$hash])) {
352
+        return $done[$hash];
353
+    }
354
+
355
+    if (!$lien = objet_associable($objet_lien)) {
356
+        return $done[$hash] = false;
357
+    }
358
+
359
+    // pas de roles sur ces objets, on sort
360
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
361
+    if (!$roles) {
362
+        return $done[$hash] = false;
363
+    }
364
+
365
+    list($primary, $l) = $lien;
366
+    $colone_role = $roles['colonne'];
367
+
368
+    $all = sql_allfetsel(
369
+        "DISTINCT $colone_role",
370
+        $l,
371
+        'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
+    );
373
+    $done[$hash] = array_map('reset', $all);
374
+
375
+    return $done[$hash];
376 376
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			$role = $roles['roles']['defaut'];
150 150
 		}
151 151
 		// where
152
-		$cond = array("$colonne_role=" . sql_quote($role));
152
+		$cond = array("$colonne_role=".sql_quote($role));
153 153
 	}
154 154
 
155 155
 	return array($role, $colonne_role, $cond);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($colonne_role) {
185 185
 		// on ajoute la condition du role aux autres conditions.
186 186
 		if ($role != '*') {
187
-			$cond[] = "$colonne_role=" . sql_quote($role);
187
+			$cond[] = "$colonne_role=".sql_quote($role);
188 188
 		}
189 189
 	}
190 190
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	$all = sql_allfetsel(
369 369
 		"DISTINCT $colone_role",
370 370
 		$l,
371
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
371
+		'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372 372
 	);
373 373
 	$done[$hash] = array_map('reset', $all);
374 374
 
Please login to merge, or discard this patch.