Completed
Push — master ( b1dd17...a00e03 )
by cam
05:16
created
config/ecran_securite.php 3 patches
Indentation   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * Test utilisateur
16 16
  */
17 17
 if (isset($_GET['test_ecran_securite']))
18
-	$ecran_securite_raison = 'test '._ECRAN_SECURITE;
18
+    $ecran_securite_raison = 'test '._ECRAN_SECURITE;
19 19
 
20 20
 /*
21 21
  * Monitoring
@@ -24,215 +24,215 @@  discard block
 block discarded – undo
24 24
  * le load depasse ECRAN_SECURITE_LOAD)
25 25
  */
26 26
 if (!defined('_IS_BOT') and isset($_GET['var_isbot'])){
27
-	define('_IS_BOT', $_GET['var_isbot'] ? true : false);
27
+    define('_IS_BOT', $_GET['var_isbot'] ? true : false);
28 28
 }
29 29
 
30 30
 /*
31 31
  * Détecteur de robot d'indexation
32 32
  */
33 33
 if (!defined('_IS_BOT')){
34
-	define('_IS_BOT',
35
-		isset($_SERVER['HTTP_USER_AGENT'])
36
-		and preg_match(','
37
-		. implode ('|', array(
38
-			// mots generiques
39
-			'bot',
40
-			'slurp',
41
-			'crawler',
42
-			'crwlr',
43
-			'java',
44
-			'monitoring',
45
-			'spider',
46
-			'webvac',
47
-			'yandex',
48
-			'MSIE 6\.0', // botnet 99,9% du temps
49
-			// UA plus cibles 
50
-			'200please',
51
-			'80legs',
52
-			'a6-indexer',
53
-			'aboundex',
54
-			'accoona',
55
-			'acrylicapps',
56
-			'addthis',
57
-			'adressendeutschland',
58
-			'alexa',
59
-			'altavista',
60
-			'analyticsseo',
61
-			'antennapod',
62
-			'arachnys',
63
-			'archive',
64
-			'argclrint',
65
-			'aspseek',
66
-			'baidu',
67
-			'begunadvertising',
68
-			'bing',
69
-			'bloglines',
70
-			'buck',
71
-			'browsershots',
72
-			'bubing',
73
-			'butterfly',
74
-			'changedetection',
75
-			'charlotte',
76
-			'chilkat',
77
-			'china',
78
-			'coccoc',
79
-			'crowsnest',
80
-			'dataminr',
81
-			'daumoa',
82
-			'dlvr\.it',
83
-			'dlweb',
84
-			'drupal',
85
-			'ec2linkfinder',
86
-			'eset\.com',
87
-			'estyle',
88
-			'exalead',
89
-			'ezooms',
90
-			'facebookexternalhit',
91
-			'facebookplatform',
92
-			'fairshare',
93
-			'feedfetcher',
94
-			'feedfetcher-google',
95
-			'feedly',
96
-			'fetch',
97
-			'flipboardproxy',
98
-			'genieo',
99
-			'google',
100
-			'go-http-client',
101
-			'grapeshot',
102
-			'hatena-useragent',
103
-			'head',
104
-			'hosttracker',
105
-			'hubspot',
106
-			'ia_archiver',
107
-			'ichiro',
108
-			'iltrovatore-setaccio',
109
-			'immediatenet',
110
-			'ina',
111
-			'inoreader',
112
-			'infegyatlas',
113
-			'infohelfer',
114
-			'instapaper',
115
-			'jabse',
116
-			'james',
117
-			'jersey',
118
-			'kumkie',
119
-			'linkdex',
120
-			'linkfluence',
121
-			'linkwalker',
122
-			'litefinder',
123
-			'loadimpactpageanalyzer',
124
-			'ltx71',
125
-			'luminate',
126
-			'lycos',
127
-			'lycosa',
128
-			'mediapartners-google',
129
-			'msai',
130
-			'myapp',
131
-			'nativehost',
132
-			'najdi',
133
-			'netcraftsurveyagent',
134
-			'netestate',
135
-			'netseer',
136
-			'netnewswire',
137
-			'newspaper',
138
-			'newsblur',
139
-			'nuhk',
140
-			'nuzzel',
141
-			'okhttp',
142
-			'otmedia',
143
-			'owlin',
144
-			'owncloud',
145
-			'panscient',
146
-			'paper\.li',
147
-			'parsijoo',
148
-			'protopage',
149
-			'plukkie',
150
-			'proximic',
151
-			'pubsub',
152
-			'python',
153
-			'qirina',
154
-			'qoshe',
155
-			'qualidator',
156
-			'qwantify',
157
-			'rambler',
158
-			'readability',
159
-			'ruby',
160
-			'sbsearch',
161
-			'scoop\.it',
162
-			'scooter',
163
-			'scoutjet',
164
-			'scrapy',
165
-			'scrubby',
166
-			'scrubbybloglines',
167
-			'shareaholic',
168
-			'shopwiki',
169
-			'simplepie',
170
-			'sistrix',
171
-			'sitechecker',
172
-			'siteexplorer',
173
-			'snapshot',
174
-			'sogou',
175
-			'special_archiver',
176
-			'speedy',
177
-			'spinn3r',
178
-			'spreadtrum',
179
-			'steeler',
180
-			'subscriber',
181
-			'suma',
182
-			'superdownloads',
183
-			'svenska-webbsido',
184
-			'teoma',
185
-			'the knowledge AI',
186
-			'thumbshots',
187
-			'tineye',
188
-			'traackr',
189
-			'trendiction',
190
-			'trendsmap',
191
-			'tweetedtimes',
192
-			'tweetmeme',
193
-			'universalfeedparser',
194
-			'uaslinkchecker',
195
-			'undrip',
196
-			'unwindfetchor',
197
-			'upday',
198
-			'vedma',
199
-			'vkshare',
200
-			'vm',
201
-			'wch',
202
-			'webalta',
203
-			'webcookies',
204
-			'webparser',
205
-			'webthumbnail',
206
-			'wesee',
207
-			'wise-guys',
208
-			'woko',
209
-			'wordpress',
210
-			'wotbox',
211
-			'y!j-bri',
212
-			'y!j-bro',
213
-			'y!j-brw',
214
-			'y!j-bsc',
215
-			'yahoo',
216
-			'yahoo!',
217
-			'yahooysmcm',
218
-			'ymobactus',
219
-			'yats',
220
-			'yeti',
221
-			'zeerch'
222
-		)) . ',i',
223
-		(string)$_SERVER['HTTP_USER_AGENT'])
224
-	);
34
+    define('_IS_BOT',
35
+        isset($_SERVER['HTTP_USER_AGENT'])
36
+        and preg_match(','
37
+        . implode ('|', array(
38
+            // mots generiques
39
+            'bot',
40
+            'slurp',
41
+            'crawler',
42
+            'crwlr',
43
+            'java',
44
+            'monitoring',
45
+            'spider',
46
+            'webvac',
47
+            'yandex',
48
+            'MSIE 6\.0', // botnet 99,9% du temps
49
+            // UA plus cibles 
50
+            '200please',
51
+            '80legs',
52
+            'a6-indexer',
53
+            'aboundex',
54
+            'accoona',
55
+            'acrylicapps',
56
+            'addthis',
57
+            'adressendeutschland',
58
+            'alexa',
59
+            'altavista',
60
+            'analyticsseo',
61
+            'antennapod',
62
+            'arachnys',
63
+            'archive',
64
+            'argclrint',
65
+            'aspseek',
66
+            'baidu',
67
+            'begunadvertising',
68
+            'bing',
69
+            'bloglines',
70
+            'buck',
71
+            'browsershots',
72
+            'bubing',
73
+            'butterfly',
74
+            'changedetection',
75
+            'charlotte',
76
+            'chilkat',
77
+            'china',
78
+            'coccoc',
79
+            'crowsnest',
80
+            'dataminr',
81
+            'daumoa',
82
+            'dlvr\.it',
83
+            'dlweb',
84
+            'drupal',
85
+            'ec2linkfinder',
86
+            'eset\.com',
87
+            'estyle',
88
+            'exalead',
89
+            'ezooms',
90
+            'facebookexternalhit',
91
+            'facebookplatform',
92
+            'fairshare',
93
+            'feedfetcher',
94
+            'feedfetcher-google',
95
+            'feedly',
96
+            'fetch',
97
+            'flipboardproxy',
98
+            'genieo',
99
+            'google',
100
+            'go-http-client',
101
+            'grapeshot',
102
+            'hatena-useragent',
103
+            'head',
104
+            'hosttracker',
105
+            'hubspot',
106
+            'ia_archiver',
107
+            'ichiro',
108
+            'iltrovatore-setaccio',
109
+            'immediatenet',
110
+            'ina',
111
+            'inoreader',
112
+            'infegyatlas',
113
+            'infohelfer',
114
+            'instapaper',
115
+            'jabse',
116
+            'james',
117
+            'jersey',
118
+            'kumkie',
119
+            'linkdex',
120
+            'linkfluence',
121
+            'linkwalker',
122
+            'litefinder',
123
+            'loadimpactpageanalyzer',
124
+            'ltx71',
125
+            'luminate',
126
+            'lycos',
127
+            'lycosa',
128
+            'mediapartners-google',
129
+            'msai',
130
+            'myapp',
131
+            'nativehost',
132
+            'najdi',
133
+            'netcraftsurveyagent',
134
+            'netestate',
135
+            'netseer',
136
+            'netnewswire',
137
+            'newspaper',
138
+            'newsblur',
139
+            'nuhk',
140
+            'nuzzel',
141
+            'okhttp',
142
+            'otmedia',
143
+            'owlin',
144
+            'owncloud',
145
+            'panscient',
146
+            'paper\.li',
147
+            'parsijoo',
148
+            'protopage',
149
+            'plukkie',
150
+            'proximic',
151
+            'pubsub',
152
+            'python',
153
+            'qirina',
154
+            'qoshe',
155
+            'qualidator',
156
+            'qwantify',
157
+            'rambler',
158
+            'readability',
159
+            'ruby',
160
+            'sbsearch',
161
+            'scoop\.it',
162
+            'scooter',
163
+            'scoutjet',
164
+            'scrapy',
165
+            'scrubby',
166
+            'scrubbybloglines',
167
+            'shareaholic',
168
+            'shopwiki',
169
+            'simplepie',
170
+            'sistrix',
171
+            'sitechecker',
172
+            'siteexplorer',
173
+            'snapshot',
174
+            'sogou',
175
+            'special_archiver',
176
+            'speedy',
177
+            'spinn3r',
178
+            'spreadtrum',
179
+            'steeler',
180
+            'subscriber',
181
+            'suma',
182
+            'superdownloads',
183
+            'svenska-webbsido',
184
+            'teoma',
185
+            'the knowledge AI',
186
+            'thumbshots',
187
+            'tineye',
188
+            'traackr',
189
+            'trendiction',
190
+            'trendsmap',
191
+            'tweetedtimes',
192
+            'tweetmeme',
193
+            'universalfeedparser',
194
+            'uaslinkchecker',
195
+            'undrip',
196
+            'unwindfetchor',
197
+            'upday',
198
+            'vedma',
199
+            'vkshare',
200
+            'vm',
201
+            'wch',
202
+            'webalta',
203
+            'webcookies',
204
+            'webparser',
205
+            'webthumbnail',
206
+            'wesee',
207
+            'wise-guys',
208
+            'woko',
209
+            'wordpress',
210
+            'wotbox',
211
+            'y!j-bri',
212
+            'y!j-bro',
213
+            'y!j-brw',
214
+            'y!j-bsc',
215
+            'yahoo',
216
+            'yahoo!',
217
+            'yahooysmcm',
218
+            'ymobactus',
219
+            'yats',
220
+            'yeti',
221
+            'zeerch'
222
+        )) . ',i',
223
+        (string)$_SERVER['HTTP_USER_AGENT'])
224
+    );
225 225
 }
226 226
 if (!defined('_IS_BOT_FRIEND')){
227
-	define('_IS_BOT_FRIEND',
228
-		isset($_SERVER['HTTP_USER_AGENT'])
229
-		and preg_match(',' . implode ('|', array(
230
-			'facebookexternalhit',
231
-			'flipboardproxy',
232
-			'wordpress'
233
-		)) . ',i',
234
-		(string)$_SERVER['HTTP_USER_AGENT'])
235
-	);
227
+    define('_IS_BOT_FRIEND',
228
+        isset($_SERVER['HTTP_USER_AGENT'])
229
+        and preg_match(',' . implode ('|', array(
230
+            'facebookexternalhit',
231
+            'flipboardproxy',
232
+            'wordpress'
233
+        )) . ',i',
234
+        (string)$_SERVER['HTTP_USER_AGENT'])
235
+    );
236 236
 }
237 237
 
238 238
 /*
@@ -244,17 +244,17 @@  discard block
 block discarded – undo
244 244
  */
245 245
 $_exceptions = array('id_table','id_base','id_parent','id_article_pdf');
246 246
 foreach ($_GET as $var => $val)
247
-	if ($_GET[$var] and strncmp($var, "id_", 3) == 0
248
-		and !in_array($var, $_exceptions))
249
-		$_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]);
247
+    if ($_GET[$var] and strncmp($var, "id_", 3) == 0
248
+        and !in_array($var, $_exceptions))
249
+        $_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]);
250 250
 foreach ($_POST as $var => $val)
251
-	if ($_POST[$var] and strncmp($var, "id_", 3) == 0
252
-		and !in_array($var, $_exceptions))
253
-		$_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]);
251
+    if ($_POST[$var] and strncmp($var, "id_", 3) == 0
252
+        and !in_array($var, $_exceptions))
253
+        $_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]);
254 254
 foreach ($GLOBALS as $var => $val)
255
-	if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0
256
-		and !in_array($var, $_exceptions))
257
-		$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]);
255
+    if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0
256
+        and !in_array($var, $_exceptions))
257
+        $GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]);
258 258
 
259 259
 /*
260 260
  * Interdit la variable $cjpeg_command, qui était utilisée sans
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
  * Contrôle de quelques variables (XSS)
267 267
  */
268 268
 foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
269
-	if (isset($_GET[$var]))
270
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
271
-	if (isset($_POST[$var]))
272
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
269
+    if (isset($_GET[$var]))
270
+        $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
271
+    if (isset($_POST[$var]))
272
+        $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
273 273
 }
274 274
 
275 275
 /*
276 276
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
277 277
  */
278 278
 if (isset($_SERVER['REQUEST_URI'])) {
279
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
280
-		$file = addslashes((string)$_GET['file']);
281
-	}
279
+    if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
280
+        $file = addslashes((string)$_GET['file']);
281
+    }
282 282
 }
283 283
 
284 284
 /*
@@ -287,61 +287,61 @@  discard block
 block discarded – undo
287 287
 if (isset($_REQUEST['mode']) and isset($_REQUEST['page'])
288 288
 and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
289 289
 and $_REQUEST['page'] == "identifiants")
290
-	$ecran_securite_raison = "identifiants";
290
+    $ecran_securite_raison = "identifiants";
291 291
 
292 292
 /*
293 293
  * Agenda joue à l'injection php
294 294
  */
295 295
 if (isset($_REQUEST['partie_cal'])
296 296
 and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']))
297
-	$ecran_securite_raison = "partie_cal";
297
+    $ecran_securite_raison = "partie_cal";
298 298
 if (isset($_REQUEST['echelle'])
299 299
 and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']))
300
-	$ecran_securite_raison = "echelle";
300
+    $ecran_securite_raison = "echelle";
301 301
 
302 302
 /*
303 303
  * Espace privé
304 304
  */
305 305
 if (isset($_REQUEST['exec'])
306 306
 and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']))
307
-	$ecran_securite_raison = "exec";
307
+    $ecran_securite_raison = "exec";
308 308
 if (isset($_REQUEST['cherche_auteur'])
309 309
 and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']))
310
-	$ecran_securite_raison = "cherche_auteur";
310
+    $ecran_securite_raison = "cherche_auteur";
311 311
 if (isset($_REQUEST['exec'])
312 312
 and $_REQUEST['exec'] == 'auteurs'
313 313
 and preg_match(',[<],', (string)$_REQUEST['recherche']))
314
-	$ecran_securite_raison = "recherche";
314
+    $ecran_securite_raison = "recherche";
315 315
 if (isset($_REQUEST['exec'])
316 316
 and $_REQUEST['exec'] == 'info_plugin'
317 317
 and preg_match(',[<],', (string)$_REQUEST['plugin']))
318
-	$ecran_securite_raison = "plugin";
318
+    $ecran_securite_raison = "plugin";
319 319
 if (isset($_REQUEST['exec'])
320 320
 and $_REQUEST['exec'] == 'puce_statut'
321 321
 and isset($_REQUEST['id'])
322 322
 and !intval($_REQUEST['id']))
323
-	$ecran_securite_raison = "puce_statut";
323
+    $ecran_securite_raison = "puce_statut";
324 324
 if (isset($_REQUEST['action'])
325 325
 and $_REQUEST['action'] == 'configurer') {
326
-	if (@file_exists('inc_version.php')
327
-	or @file_exists('ecrire/inc_version.php')) {
328
-		function action_configurer() {
329
-			include_spip('inc/autoriser');
330
-			if(!autoriser('configurer', _request('configuration'))) {
331
-				include_spip('inc/minipres');
332
-				echo minipres(_T('info_acces_interdit'));
333
-				exit;
334
-			}
335
-			require _DIR_RESTREINT.'action/configurer.php';
336
-			action_configurer_dist();
337
-		}
338
-	}
326
+    if (@file_exists('inc_version.php')
327
+    or @file_exists('ecrire/inc_version.php')) {
328
+        function action_configurer() {
329
+            include_spip('inc/autoriser');
330
+            if(!autoriser('configurer', _request('configuration'))) {
331
+                include_spip('inc/minipres');
332
+                echo minipres(_T('info_acces_interdit'));
333
+                exit;
334
+            }
335
+            require _DIR_RESTREINT.'action/configurer.php';
336
+            action_configurer_dist();
337
+        }
338
+    }
339 339
 }
340 340
 if (isset($_REQUEST['action'])
341 341
 and $_REQUEST['action'] == 'ordonner_liens_documents'
342 342
 and isset($_REQUEST['ordre'])
343 343
 and is_string($_REQUEST['ordre'])){
344
-	$ecran_securite_raison = "ordre a la chaine";
344
+    $ecran_securite_raison = "ordre a la chaine";
345 345
 }
346 346
 
347 347
 
@@ -349,24 +349,24 @@  discard block
 block discarded – undo
349 349
  * Bloque les requêtes contenant %00 (manipulation d'include)
350 350
  */
351 351
 if (strpos(
352
-	(function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) ?
353
-		stripslashes(serialize($_REQUEST)) : serialize($_REQUEST),
354
-	chr(0)
352
+    (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) ?
353
+        stripslashes(serialize($_REQUEST)) : serialize($_REQUEST),
354
+    chr(0)
355 355
 ) !== false)
356
-	$ecran_securite_raison = "%00";
356
+    $ecran_securite_raison = "%00";
357 357
 
358 358
 /*
359 359
  * Bloque les requêtes fond=formulaire_
360 360
  */
361 361
 if (isset($_REQUEST['fond'])
362 362
 and preg_match(',^formulaire_,i', $_REQUEST['fond']))
363
-	$ecran_securite_raison = "fond=formulaire_";
363
+    $ecran_securite_raison = "fond=formulaire_";
364 364
 
365 365
 /*
366 366
  * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
367 367
  */
368 368
 if (isset($_REQUEST['GLOBALS']))
369
-	$ecran_securite_raison = "GLOBALS[GLOBALS]";
369
+    $ecran_securite_raison = "GLOBALS[GLOBALS]";
370 370
 
371 371
 /*
372 372
  * Bloque les requêtes des bots sur:
@@ -374,26 +374,26 @@  discard block
 block discarded – undo
374 374
  * les paginations entremélées
375 375
  */
376 376
 if (_IS_BOT and (
377
-	(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
378
-	or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
379
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_') )
380
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
377
+    (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
378
+    or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
379
+        or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_') )
380
+        or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
381 381
 )
382 382
 )
383
-	$ecran_securite_raison = "robot agenda/double pagination";
383
+    $ecran_securite_raison = "robot agenda/double pagination";
384 384
 
385 385
 /*
386 386
  * Bloque une vieille page de tests de CFG (<1.11)
387 387
  * Bloque un XSS sur une page inexistante
388 388
  */
389 389
 if (isset($_REQUEST['page'])) {
390
-	if ($_REQUEST['page'] == 'test_cfg')
391
-		$ecran_securite_raison = "test_cfg";
392
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
393
-		$ecran_securite_raison = "xsspage";
394
-	if ($_REQUEST['page'] == '404'
395
-	and isset($_REQUEST['erreur']))
396
-		$ecran_securite_raison = "xss404";
390
+    if ($_REQUEST['page'] == 'test_cfg')
391
+        $ecran_securite_raison = "test_cfg";
392
+    if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
393
+        $ecran_securite_raison = "xsspage";
394
+    if ($_REQUEST['page'] == '404'
395
+    and isset($_REQUEST['erreur']))
396
+        $ecran_securite_raison = "xss404";
397 397
 }
398 398
 
399 399
 /*
@@ -401,40 +401,40 @@  discard block
 block discarded – undo
401 401
  */
402 402
 foreach (array('var_login') as $var)
403 403
 if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var]))
404
-	$ecran_securite_raison = "xss ".$var;
404
+    $ecran_securite_raison = "xss ".$var;
405 405
 
406 406
 /*
407 407
  * Parade antivirale contre un cheval de troie
408 408
  */
409 409
 if (!function_exists('tmp_lkojfghx')) {
410
-	function tmp_lkojfghx() {}
411
-	function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
412
-		// si jamais on est arrivé ici sur une erreur php
413
-		// et qu'un autre gestionnaire d'erreur est défini, l'appeller
414
-		if ($b && $GLOBALS['tmp_xhgfjokl'])
415
-			call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
416
-	}
410
+    function tmp_lkojfghx() {}
411
+    function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
412
+        // si jamais on est arrivé ici sur une erreur php
413
+        // et qu'un autre gestionnaire d'erreur est défini, l'appeller
414
+        if ($b && $GLOBALS['tmp_xhgfjokl'])
415
+            call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
416
+    }
417 417
 }
418 418
 if (isset($_POST['tmp_lkojfghx3']))
419
-	$ecran_securite_raison = "gumblar";
419
+    $ecran_securite_raison = "gumblar";
420 420
 
421 421
 /*
422 422
  * Outils XML mal sécurisés < 2.0.9
423 423
  */
424 424
 if (isset($_REQUEST['transformer_xml']))
425
-	$ecran_securite_raison = "transformer_xml";
425
+    $ecran_securite_raison = "transformer_xml";
426 426
 
427 427
 /*
428 428
  * Outils XML mal sécurisés again
429 429
  */
430 430
 if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec']=='valider_xml'){
431
-	$url = trim($_REQUEST['var_url']);
432
-	if (strncmp($url,'/',1)==0
433
-	  or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false)
434
-	  or (($p=strpos($url,'..'))!==false AND strpos($url,'IMG',$p+3)!==false)
435
-		or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) {
436
-		$ecran_securite_raison = 'URL interdite pour var_url';
437
-	}
431
+    $url = trim($_REQUEST['var_url']);
432
+    if (strncmp($url,'/',1)==0
433
+      or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false)
434
+      or (($p=strpos($url,'..'))!==false AND strpos($url,'IMG',$p+3)!==false)
435
+        or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) {
436
+        $ecran_securite_raison = 'URL interdite pour var_url';
437
+    }
438 438
 }
439 439
 
440 440
 /*
@@ -442,10 +442,10 @@  discard block
 block discarded – undo
442 442
  */
443 443
 if (isset($_REQUEST['nom_sauvegarde'])
444 444
 and strstr((string)$_REQUEST['nom_sauvegarde'], '/'))
445
-	$ecran_securite_raison = 'nom_sauvegarde manipulee';
445
+    $ecran_securite_raison = 'nom_sauvegarde manipulee';
446 446
 if (isset($_REQUEST['znom_sauvegarde'])
447 447
 and strstr((string)$_REQUEST['znom_sauvegarde'], '/'))
448
-	$ecran_securite_raison = 'znom_sauvegarde manipulee';
448
+    $ecran_securite_raison = 'znom_sauvegarde manipulee';
449 449
 
450 450
 
451 451
 /*
@@ -454,26 +454,26 @@  discard block
 block discarded – undo
454 454
  */
455 455
 if (isset($_REQUEST['op']) and isset($_REQUEST['page'])
456 456
 and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op']))
457
-	$ecran_securite_raison = 'op';
457
+    $ecran_securite_raison = 'op';
458 458
 
459 459
 /*
460 460
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
461 461
  */
462 462
 if (count($_FILES)){
463
-	foreach($_FILES as $k => $v){
464
-		 if (preg_match(',^fichier_\d+$,', $k)
465
-		 and preg_match(',\.php,i', $v['name']))
466
-		 	unset($_FILES[$k]);
467
-	}
463
+    foreach($_FILES as $k => $v){
464
+            if (preg_match(',^fichier_\d+$,', $k)
465
+         and preg_match(',\.php,i', $v['name']))
466
+                unset($_FILES[$k]);
467
+    }
468 468
 }
469 469
 /*
470 470
  * et Contact trop laxiste avec une variable externe
471 471
  * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
472 472
  */
473 473
 if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']){
474
-	unset($_REQUEST['pj_enregistrees_nom']);
475
-	unset($_GET['pj_enregistrees_nom']);
476
-	unset($_POST['pj_enregistrees_nom']);
474
+    unset($_REQUEST['pj_enregistrees_nom']);
475
+    unset($_GET['pj_enregistrees_nom']);
476
+    unset($_POST['pj_enregistrees_nom']);
477 477
 }
478 478
 
479 479
 /*
@@ -481,35 +481,35 @@  discard block
 block discarded – undo
481 481
  */
482 482
 if (isset($_REQUEST['reinstall'])
483 483
 and $_REQUEST['reinstall'] == 'oui')
484
-	$ecran_securite_raison = 'reinstall=oui';
484
+    $ecran_securite_raison = 'reinstall=oui';
485 485
 
486 486
 /*
487 487
  * Pas d'action pendant l'install
488 488
  */
489 489
 if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQUEST['action'])) {
490
-	$ecran_securite_raison = 'install&action impossibles';
490
+    $ecran_securite_raison = 'install&action impossibles';
491 491
 }
492 492
 
493 493
 /*
494 494
  * Échappement xss referer
495 495
  */
496 496
 if (isset($_SERVER['HTTP_REFERER']))
497
-	$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
497
+    $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
498 498
 
499 499
 
500 500
 /*
501 501
  * Echappement HTTP_X_FORWARDED_HOST
502 502
  */
503 503
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
504
-	$_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
504
+    $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
505 505
 
506 506
 
507 507
 /*
508 508
  * Pas d'erreur dans l'erreur
509 509
  */
510 510
 if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') {
511
-	if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>'))
512
-		$ecran_securite_raison = 'var_erreur incorrecte';
511
+    if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>'))
512
+        $ecran_securite_raison = 'var_erreur incorrecte';
513 513
 }
514 514
 
515 515
 
@@ -517,49 +517,49 @@  discard block
 block discarded – undo
517 517
  * Réinjection des clés en html dans l'admin r19561
518 518
  */
519 519
 if (
520
-	(isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
521
-	or isset($_REQUEST['var_memotri'])
520
+    (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
521
+    or isset($_REQUEST['var_memotri'])
522 522
 ){
523
-	$zzzz = implode("", array_keys($_REQUEST));
524
-	if (strlen($zzzz) != strcspn($zzzz, '<>"\''))
525
-		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
523
+    $zzzz = implode("", array_keys($_REQUEST));
524
+    if (strlen($zzzz) != strcspn($zzzz, '<>"\''))
525
+        $ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
526 526
 }
527 527
 
528 528
 /*
529 529
  * Injection par connect
530 530
  */
531 531
 if (isset($_REQUEST['connect'])
532
-	and
533
-	// cas qui permettent de sortir d'un commentaire PHP
534
-	(strpos($_REQUEST['connect'], "?") !== false
535
-	 or strpos($_REQUEST['connect'], "<") !== false
536
-	 or strpos($_REQUEST['connect'], ">") !== false
537
-	 or strpos($_REQUEST['connect'], "\n") !== false
538
-	 or strpos($_REQUEST['connect'], "\r") !== false)
539
-	) {
540
-	$ecran_securite_raison = "malformed connect argument";
532
+    and
533
+    // cas qui permettent de sortir d'un commentaire PHP
534
+    (strpos($_REQUEST['connect'], "?") !== false
535
+     or strpos($_REQUEST['connect'], "<") !== false
536
+     or strpos($_REQUEST['connect'], ">") !== false
537
+     or strpos($_REQUEST['connect'], "\n") !== false
538
+     or strpos($_REQUEST['connect'], "\r") !== false)
539
+    ) {
540
+    $ecran_securite_raison = "malformed connect argument";
541 541
 }
542 542
 
543 543
 /*
544 544
  * S'il y a une raison de mourir, mourons
545 545
  */
546 546
 if (isset($ecran_securite_raison)) {
547
-	header("HTTP/1.0 403 Forbidden");
548
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
549
-	header("Cache-Control: no-cache, must-revalidate");
550
-	header("Pragma: no-cache");
551
-	header("Content-Type: text/html");
552
-	die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
547
+    header("HTTP/1.0 403 Forbidden");
548
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
549
+    header("Cache-Control: no-cache, must-revalidate");
550
+    header("Pragma: no-cache");
551
+    header("Content-Type: text/html");
552
+    die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
553 553
 }
554 554
 
555 555
 /*
556 556
  * Un filtre filtrer_entites securise
557 557
  */
558 558
 if (!function_exists('filtre_filtrer_entites_dist')) {
559
-	function filtre_filtrer_entites_dist($t) {
560
-		include_spip('inc/texte');
561
-		return interdire_scripts(filtrer_entites($t));
562
-	}
559
+    function filtre_filtrer_entites_dist($t) {
560
+        include_spip('inc/texte');
561
+        return interdire_scripts(filtrer_entites($t));
562
+    }
563 563
 }
564 564
 
565 565
 
@@ -573,36 +573,36 @@  discard block
 block discarded – undo
573 573
  * Bloque les bots quand le load déborde
574 574
  */
575 575
 if (!defined('_ECRAN_SECURITE_LOAD'))
576
-	define('_ECRAN_SECURITE_LOAD', 4);
576
+    define('_ECRAN_SECURITE_LOAD', 4);
577 577
 
578 578
 if (
579
-	defined('_ECRAN_SECURITE_LOAD')
580
-	and _ECRAN_SECURITE_LOAD > 0
581
-	and _IS_BOT
582
-	and !_IS_BOT_FRIEND
583
-	and $_SERVER['REQUEST_METHOD'] === 'GET'
584
-	and (
585
-		(function_exists('sys_getloadavg')
586
-		  and $load = sys_getloadavg()
587
-		  and is_array($load)
588
-		  and $load = array_shift($load)
589
-		)
590
-		or
591
-		(@is_readable('/proc/loadavg')
592
-		  and $load = file_get_contents('/proc/loadavg')
593
-		  and $load = floatval($load)
594
-		)
595
-	)
596
-	and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
597
-	and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
579
+    defined('_ECRAN_SECURITE_LOAD')
580
+    and _ECRAN_SECURITE_LOAD > 0
581
+    and _IS_BOT
582
+    and !_IS_BOT_FRIEND
583
+    and $_SERVER['REQUEST_METHOD'] === 'GET'
584
+    and (
585
+        (function_exists('sys_getloadavg')
586
+          and $load = sys_getloadavg()
587
+          and is_array($load)
588
+          and $load = array_shift($load)
589
+        )
590
+        or
591
+        (@is_readable('/proc/loadavg')
592
+          and $load = file_get_contents('/proc/loadavg')
593
+          and $load = floatval($load)
594
+        )
595
+    )
596
+    and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
597
+    and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
598 598
 ) {
599
-	//https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
600
-	header("HTTP/1.0 429 Too Many Requests");
601
-	header("Retry-After: 300");
602
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
603
-	header("Cache-Control: no-cache, must-revalidate");
604
-	header("Pragma: no-cache");
605
-	header("Content-Type: text/html");
606
-	die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
599
+    //https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
600
+    header("HTTP/1.0 429 Too Many Requests");
601
+    header("Retry-After: 300");
602
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
603
+    header("Cache-Control: no-cache, must-revalidate");
604
+    header("Pragma: no-cache");
605
+    header("Content-Type: text/html");
606
+    die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
607 607
 }
608 608
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
  * var_isbot=1 peut etre utilise pour monitorer la disponibilite pour les bots (sujets a 503 de delestage si
24 24
  * le load depasse ECRAN_SECURITE_LOAD)
25 25
  */
26
-if (!defined('_IS_BOT') and isset($_GET['var_isbot'])){
26
+if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) {
27 27
 	define('_IS_BOT', $_GET['var_isbot'] ? true : false);
28 28
 }
29 29
 
30 30
 /*
31 31
  * Détecteur de robot d'indexation
32 32
  */
33
-if (!defined('_IS_BOT')){
33
+if (!defined('_IS_BOT')) {
34 34
 	define('_IS_BOT',
35 35
 		isset($_SERVER['HTTP_USER_AGENT'])
36 36
 		and preg_match(','
37
-		. implode ('|', array(
37
+		. implode('|', array(
38 38
 			// mots generiques
39 39
 			'bot',
40 40
 			'slurp',
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
 			'yats',
220 220
 			'yeti',
221 221
 			'zeerch'
222
-		)) . ',i',
223
-		(string)$_SERVER['HTTP_USER_AGENT'])
222
+		)).',i',
223
+		(string) $_SERVER['HTTP_USER_AGENT'])
224 224
 	);
225 225
 }
226
-if (!defined('_IS_BOT_FRIEND')){
226
+if (!defined('_IS_BOT_FRIEND')) {
227 227
 	define('_IS_BOT_FRIEND',
228 228
 		isset($_SERVER['HTTP_USER_AGENT'])
229
-		and preg_match(',' . implode ('|', array(
229
+		and preg_match(','.implode('|', array(
230 230
 			'facebookexternalhit',
231 231
 			'flipboardproxy',
232 232
 			'wordpress'
233
-		)) . ',i',
234
-		(string)$_SERVER['HTTP_USER_AGENT'])
233
+		)).',i',
234
+		(string) $_SERVER['HTTP_USER_AGENT'])
235 235
 	);
236 236
 }
237 237
 
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
  * (sauf pour id_table, qui n'est pas numérique jusqu'à [5743])
243 243
  * (id_base est une variable de la config des widgets de WordPress)
244 244
  */
245
-$_exceptions = array('id_table','id_base','id_parent','id_article_pdf');
245
+$_exceptions = array('id_table', 'id_base', 'id_parent', 'id_article_pdf');
246 246
 foreach ($_GET as $var => $val)
247 247
 	if ($_GET[$var] and strncmp($var, "id_", 3) == 0
248 248
 		and !in_array($var, $_exceptions))
249
-		$_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]);
249
+		$_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
250 250
 foreach ($_POST as $var => $val)
251 251
 	if ($_POST[$var] and strncmp($var, "id_", 3) == 0
252 252
 		and !in_array($var, $_exceptions))
253
-		$_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]);
253
+		$_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
254 254
 foreach ($GLOBALS as $var => $val)
255 255
 	if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0
256 256
 		and !in_array($var, $_exceptions))
257
-		$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]);
257
+		$GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
258 258
 
259 259
 /*
260 260
  * Interdit la variable $cjpeg_command, qui était utilisée sans
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
 /*
266 266
  * Contrôle de quelques variables (XSS)
267 267
  */
268
-foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
268
+foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
269 269
 	if (isset($_GET[$var]))
270
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
270
+		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_GET[$var]);
271 271
 	if (isset($_POST[$var]))
272
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
272
+		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_POST[$var]);
273 273
 }
274 274
 
275 275
 /*
276 276
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
277 277
  */
278 278
 if (isset($_SERVER['REQUEST_URI'])) {
279
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
280
-		$file = addslashes((string)$_GET['file']);
279
+	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string) $_SERVER['REQUEST_URI'])) {
280
+		$file = addslashes((string) $_GET['file']);
281 281
 	}
282 282
 }
283 283
 
@@ -293,28 +293,28 @@  discard block
 block discarded – undo
293 293
  * Agenda joue à l'injection php
294 294
  */
295 295
 if (isset($_REQUEST['partie_cal'])
296
-and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']))
296
+and $_REQUEST['partie_cal'] !== htmlentities((string) $_REQUEST['partie_cal']))
297 297
 	$ecran_securite_raison = "partie_cal";
298 298
 if (isset($_REQUEST['echelle'])
299
-and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']))
299
+and $_REQUEST['echelle'] !== htmlentities((string) $_REQUEST['echelle']))
300 300
 	$ecran_securite_raison = "echelle";
301 301
 
302 302
 /*
303 303
  * Espace privé
304 304
  */
305 305
 if (isset($_REQUEST['exec'])
306
-and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']))
306
+and !preg_match(',^[\w-]+$,', (string) $_REQUEST['exec']))
307 307
 	$ecran_securite_raison = "exec";
308 308
 if (isset($_REQUEST['cherche_auteur'])
309
-and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']))
309
+and preg_match(',[<],', (string) $_REQUEST['cherche_auteur']))
310 310
 	$ecran_securite_raison = "cherche_auteur";
311 311
 if (isset($_REQUEST['exec'])
312 312
 and $_REQUEST['exec'] == 'auteurs'
313
-and preg_match(',[<],', (string)$_REQUEST['recherche']))
313
+and preg_match(',[<],', (string) $_REQUEST['recherche']))
314 314
 	$ecran_securite_raison = "recherche";
315 315
 if (isset($_REQUEST['exec'])
316 316
 and $_REQUEST['exec'] == 'info_plugin'
317
-and preg_match(',[<],', (string)$_REQUEST['plugin']))
317
+and preg_match(',[<],', (string) $_REQUEST['plugin']))
318 318
 	$ecran_securite_raison = "plugin";
319 319
 if (isset($_REQUEST['exec'])
320 320
 and $_REQUEST['exec'] == 'puce_statut'
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	or @file_exists('ecrire/inc_version.php')) {
328 328
 		function action_configurer() {
329 329
 			include_spip('inc/autoriser');
330
-			if(!autoriser('configurer', _request('configuration'))) {
330
+			if (!autoriser('configurer', _request('configuration'))) {
331 331
 				include_spip('inc/minipres');
332 332
 				echo minipres(_T('info_acces_interdit'));
333 333
 				exit;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 if (isset($_REQUEST['action'])
341 341
 and $_REQUEST['action'] == 'ordonner_liens_documents'
342 342
 and isset($_REQUEST['ordre'])
343
-and is_string($_REQUEST['ordre'])){
343
+and is_string($_REQUEST['ordre'])) {
344 344
 	$ecran_securite_raison = "ordre a la chaine";
345 345
 }
346 346
 
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
  */
376 376
 if (_IS_BOT and (
377 377
 	(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
378
-	or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
379
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_') )
380
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
378
+	or (strpos((string) $_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string) $_SERVER['REQUEST_URI']))
379
+		or (isset($_REQUEST['calendrier_annee']) and strpos((string) $_SERVER['REQUEST_URI'], 'debut_'))
380
+		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string) $_SERVER['REQUEST_URI']))
381 381
 )
382 382
 )
383 383
 	$ecran_securite_raison = "robot agenda/double pagination";
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 if (isset($_REQUEST['page'])) {
390 390
 	if ($_REQUEST['page'] == 'test_cfg')
391 391
 		$ecran_securite_raison = "test_cfg";
392
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
392
+	if ($_REQUEST['page'] !== htmlspecialchars((string) $_REQUEST['page']))
393 393
 		$ecran_securite_raison = "xsspage";
394 394
 	if ($_REQUEST['page'] == '404'
395 395
 	and isset($_REQUEST['erreur']))
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
 /*
428 428
  * Outils XML mal sécurisés again
429 429
  */
430
-if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec']=='valider_xml'){
430
+if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') {
431 431
 	$url = trim($_REQUEST['var_url']);
432
-	if (strncmp($url,'/',1)==0
433
-	  or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false)
434
-	  or (($p=strpos($url,'..'))!==false AND strpos($url,'IMG',$p+3)!==false)
435
-		or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) {
432
+	if (strncmp($url, '/', 1) == 0
433
+	  or (($p = strpos($url, '..')) !== false AND strpos($url, '..', $p + 3) !== false)
434
+	  or (($p = strpos($url, '..')) !== false AND strpos($url, 'IMG', $p + 3) !== false)
435
+		or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)) {
436 436
 		$ecran_securite_raison = 'URL interdite pour var_url';
437 437
 	}
438 438
 }
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
  * Sauvegarde mal securisée < 2.0.9
442 442
  */
443 443
 if (isset($_REQUEST['nom_sauvegarde'])
444
-and strstr((string)$_REQUEST['nom_sauvegarde'], '/'))
444
+and strstr((string) $_REQUEST['nom_sauvegarde'], '/'))
445 445
 	$ecran_securite_raison = 'nom_sauvegarde manipulee';
446 446
 if (isset($_REQUEST['znom_sauvegarde'])
447
-and strstr((string)$_REQUEST['znom_sauvegarde'], '/'))
447
+and strstr((string) $_REQUEST['znom_sauvegarde'], '/'))
448 448
 	$ecran_securite_raison = 'znom_sauvegarde manipulee';
449 449
 
450 450
 
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 /*
460 460
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
461 461
  */
462
-if (count($_FILES)){
463
-	foreach($_FILES as $k => $v){
462
+if (count($_FILES)) {
463
+	foreach ($_FILES as $k => $v) {
464 464
 		 if (preg_match(',^fichier_\d+$,', $k)
465 465
 		 and preg_match(',\.php,i', $v['name']))
466 466
 		 	unset($_FILES[$k]);
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * et Contact trop laxiste avec une variable externe
471 471
  * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
472 472
  */
473
-if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']){
473
+if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) {
474 474
 	unset($_REQUEST['pj_enregistrees_nom']);
475 475
 	unset($_GET['pj_enregistrees_nom']);
476 476
 	unset($_POST['pj_enregistrees_nom']);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 if (
520 520
 	(isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
521 521
 	or isset($_REQUEST['var_memotri'])
522
-){
522
+) {
523 523
 	$zzzz = implode("", array_keys($_REQUEST));
524 524
 	if (strlen($zzzz) != strcspn($zzzz, '<>"\''))
525 525
 		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
Please login to merge, or discard this patch.
Braces   +84 added lines, -49 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 /*
15 15
  * Test utilisateur
16 16
  */
17
-if (isset($_GET['test_ecran_securite']))
17
+if (isset($_GET['test_ecran_securite'])) {
18 18
 	$ecran_securite_raison = 'test '._ECRAN_SECURITE;
19
+}
19 20
 
20 21
 /*
21 22
  * Monitoring
@@ -243,18 +244,21 @@  discard block
 block discarded – undo
243 244
  * (id_base est une variable de la config des widgets de WordPress)
244 245
  */
245 246
 $_exceptions = array('id_table','id_base','id_parent','id_article_pdf');
246
-foreach ($_GET as $var => $val)
247
+foreach ($_GET as $var => $val) {
247 248
 	if ($_GET[$var] and strncmp($var, "id_", 3) == 0
248 249
 		and !in_array($var, $_exceptions))
249 250
 		$_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]);
250
-foreach ($_POST as $var => $val)
251
+}
252
+foreach ($_POST as $var => $val) {
251 253
 	if ($_POST[$var] and strncmp($var, "id_", 3) == 0
252 254
 		and !in_array($var, $_exceptions))
253 255
 		$_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]);
254
-foreach ($GLOBALS as $var => $val)
256
+}
257
+foreach ($GLOBALS as $var => $val) {
255 258
 	if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0
256 259
 		and !in_array($var, $_exceptions))
257 260
 		$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]);
261
+}
258 262
 
259 263
 /*
260 264
  * Interdit la variable $cjpeg_command, qui était utilisée sans
@@ -266,11 +270,13 @@  discard block
 block discarded – undo
266 270
  * Contrôle de quelques variables (XSS)
267 271
  */
268 272
 foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
269
-	if (isset($_GET[$var]))
270
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
271
-	if (isset($_POST[$var]))
272
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
273
-}
273
+	if (isset($_GET[$var])) {
274
+			$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
275
+	}
276
+	if (isset($_POST[$var])) {
277
+			$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
278
+	}
279
+	}
274 280
 
275 281
 /*
276 282
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
@@ -286,41 +292,49 @@  discard block
 block discarded – undo
286 292
  */
287 293
 if (isset($_REQUEST['mode']) and isset($_REQUEST['page'])
288 294
 and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
289
-and $_REQUEST['page'] == "identifiants")
295
+and $_REQUEST['page'] == "identifiants") {
290 296
 	$ecran_securite_raison = "identifiants";
297
+}
291 298
 
292 299
 /*
293 300
  * Agenda joue à l'injection php
294 301
  */
295 302
 if (isset($_REQUEST['partie_cal'])
296
-and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']))
303
+and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])) {
297 304
 	$ecran_securite_raison = "partie_cal";
305
+}
298 306
 if (isset($_REQUEST['echelle'])
299
-and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']))
307
+and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])) {
300 308
 	$ecran_securite_raison = "echelle";
309
+}
301 310
 
302 311
 /*
303 312
  * Espace privé
304 313
  */
305 314
 if (isset($_REQUEST['exec'])
306
-and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']))
315
+and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])) {
307 316
 	$ecran_securite_raison = "exec";
317
+}
308 318
 if (isset($_REQUEST['cherche_auteur'])
309
-and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']))
319
+and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])) {
310 320
 	$ecran_securite_raison = "cherche_auteur";
321
+}
311 322
 if (isset($_REQUEST['exec'])
312 323
 and $_REQUEST['exec'] == 'auteurs'
313
-and preg_match(',[<],', (string)$_REQUEST['recherche']))
324
+and preg_match(',[<],', (string)$_REQUEST['recherche'])) {
314 325
 	$ecran_securite_raison = "recherche";
326
+}
315 327
 if (isset($_REQUEST['exec'])
316 328
 and $_REQUEST['exec'] == 'info_plugin'
317
-and preg_match(',[<],', (string)$_REQUEST['plugin']))
329
+and preg_match(',[<],', (string)$_REQUEST['plugin'])) {
318 330
 	$ecran_securite_raison = "plugin";
331
+}
319 332
 if (isset($_REQUEST['exec'])
320 333
 and $_REQUEST['exec'] == 'puce_statut'
321 334
 and isset($_REQUEST['id'])
322
-and !intval($_REQUEST['id']))
335
+and !intval($_REQUEST['id'])) {
323 336
 	$ecran_securite_raison = "puce_statut";
337
+}
324 338
 if (isset($_REQUEST['action'])
325 339
 and $_REQUEST['action'] == 'configurer') {
326 340
 	if (@file_exists('inc_version.php')
@@ -352,21 +366,24 @@  discard block
 block discarded – undo
352 366
 	(function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) ?
353 367
 		stripslashes(serialize($_REQUEST)) : serialize($_REQUEST),
354 368
 	chr(0)
355
-) !== false)
369
+) !== false) {
356 370
 	$ecran_securite_raison = "%00";
371
+}
357 372
 
358 373
 /*
359 374
  * Bloque les requêtes fond=formulaire_
360 375
  */
361 376
 if (isset($_REQUEST['fond'])
362
-and preg_match(',^formulaire_,i', $_REQUEST['fond']))
377
+and preg_match(',^formulaire_,i', $_REQUEST['fond'])) {
363 378
 	$ecran_securite_raison = "fond=formulaire_";
379
+}
364 380
 
365 381
 /*
366 382
  * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
367 383
  */
368
-if (isset($_REQUEST['GLOBALS']))
384
+if (isset($_REQUEST['GLOBALS'])) {
369 385
 	$ecran_securite_raison = "GLOBALS[GLOBALS]";
386
+}
370 387
 
371 388
 /*
372 389
  * Bloque les requêtes des bots sur:
@@ -379,29 +396,34 @@  discard block
 block discarded – undo
379 396
 		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_') )
380 397
 		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
381 398
 )
382
-)
399
+) {
383 400
 	$ecran_securite_raison = "robot agenda/double pagination";
401
+}
384 402
 
385 403
 /*
386 404
  * Bloque une vieille page de tests de CFG (<1.11)
387 405
  * Bloque un XSS sur une page inexistante
388 406
  */
389 407
 if (isset($_REQUEST['page'])) {
390
-	if ($_REQUEST['page'] == 'test_cfg')
391
-		$ecran_securite_raison = "test_cfg";
392
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
393
-		$ecran_securite_raison = "xsspage";
408
+	if ($_REQUEST['page'] == 'test_cfg') {
409
+			$ecran_securite_raison = "test_cfg";
410
+	}
411
+	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
412
+			$ecran_securite_raison = "xsspage";
413
+	}
394 414
 	if ($_REQUEST['page'] == '404'
395
-	and isset($_REQUEST['erreur']))
396
-		$ecran_securite_raison = "xss404";
397
-}
415
+	and isset($_REQUEST['erreur'])) {
416
+			$ecran_securite_raison = "xss404";
417
+	}
418
+	}
398 419
 
399 420
 /*
400 421
  * XSS par array
401 422
  */
402
-foreach (array('var_login') as $var)
403
-if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var]))
423
+foreach (array('var_login') as $var) {
424
+    if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var]))
404 425
 	$ecran_securite_raison = "xss ".$var;
426
+}
405 427
 
406 428
 /*
407 429
  * Parade antivirale contre un cheval de troie
@@ -411,18 +433,21 @@  discard block
 block discarded – undo
411 433
 	function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
412 434
 		// si jamais on est arrivé ici sur une erreur php
413 435
 		// et qu'un autre gestionnaire d'erreur est défini, l'appeller
414
-		if ($b && $GLOBALS['tmp_xhgfjokl'])
415
-			call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
436
+		if ($b && $GLOBALS['tmp_xhgfjokl']) {
437
+					call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
438
+		}
416 439
 	}
417 440
 }
418
-if (isset($_POST['tmp_lkojfghx3']))
441
+if (isset($_POST['tmp_lkojfghx3'])) {
419 442
 	$ecran_securite_raison = "gumblar";
443
+}
420 444
 
421 445
 /*
422 446
  * Outils XML mal sécurisés < 2.0.9
423 447
  */
424
-if (isset($_REQUEST['transformer_xml']))
448
+if (isset($_REQUEST['transformer_xml'])) {
425 449
 	$ecran_securite_raison = "transformer_xml";
450
+}
426 451
 
427 452
 /*
428 453
  * Outils XML mal sécurisés again
@@ -441,11 +466,13 @@  discard block
 block discarded – undo
441 466
  * Sauvegarde mal securisée < 2.0.9
442 467
  */
443 468
 if (isset($_REQUEST['nom_sauvegarde'])
444
-and strstr((string)$_REQUEST['nom_sauvegarde'], '/'))
469
+and strstr((string)$_REQUEST['nom_sauvegarde'], '/')) {
445 470
 	$ecran_securite_raison = 'nom_sauvegarde manipulee';
471
+}
446 472
 if (isset($_REQUEST['znom_sauvegarde'])
447
-and strstr((string)$_REQUEST['znom_sauvegarde'], '/'))
473
+and strstr((string)$_REQUEST['znom_sauvegarde'], '/')) {
448 474
 	$ecran_securite_raison = 'znom_sauvegarde manipulee';
475
+}
449 476
 
450 477
 
451 478
 /*
@@ -453,8 +480,9 @@  discard block
 block discarded – undo
453 480
  * on vérifie 'page' pour ne pas bloquer ... drupal
454 481
  */
455 482
 if (isset($_REQUEST['op']) and isset($_REQUEST['page'])
456
-and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op']))
483
+and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op'])) {
457 484
 	$ecran_securite_raison = 'op';
485
+}
458 486
 
459 487
 /*
460 488
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
@@ -462,8 +490,9 @@  discard block
 block discarded – undo
462 490
 if (count($_FILES)){
463 491
 	foreach($_FILES as $k => $v){
464 492
 		 if (preg_match(',^fichier_\d+$,', $k)
465
-		 and preg_match(',\.php,i', $v['name']))
466
-		 	unset($_FILES[$k]);
493
+		 and preg_match(',\.php,i', $v['name'])) {
494
+		 		 	unset($_FILES[$k]);
495
+		 }
467 496
 	}
468 497
 }
469 498
 /*
@@ -480,8 +509,9 @@  discard block
 block discarded – undo
480 509
  * reinstall=oui un peu trop permissif
481 510
  */
482 511
 if (isset($_REQUEST['reinstall'])
483
-and $_REQUEST['reinstall'] == 'oui')
512
+and $_REQUEST['reinstall'] == 'oui') {
484 513
 	$ecran_securite_raison = 'reinstall=oui';
514
+}
485 515
 
486 516
 /*
487 517
  * Pas d'action pendant l'install
@@ -493,24 +523,27 @@  discard block
 block discarded – undo
493 523
 /*
494 524
  * Échappement xss referer
495 525
  */
496
-if (isset($_SERVER['HTTP_REFERER']))
526
+if (isset($_SERVER['HTTP_REFERER'])) {
497 527
 	$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
528
+}
498 529
 
499 530
 
500 531
 /*
501 532
  * Echappement HTTP_X_FORWARDED_HOST
502 533
  */
503
-if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
534
+if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
504 535
 	$_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
536
+}
505 537
 
506 538
 
507 539
 /*
508 540
  * Pas d'erreur dans l'erreur
509 541
  */
510 542
 if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') {
511
-	if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>'))
512
-		$ecran_securite_raison = 'var_erreur incorrecte';
513
-}
543
+	if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
544
+			$ecran_securite_raison = 'var_erreur incorrecte';
545
+	}
546
+	}
514 547
 
515 548
 
516 549
 /*
@@ -521,9 +554,10 @@  discard block
 block discarded – undo
521 554
 	or isset($_REQUEST['var_memotri'])
522 555
 ){
523 556
 	$zzzz = implode("", array_keys($_REQUEST));
524
-	if (strlen($zzzz) != strcspn($zzzz, '<>"\''))
525
-		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
526
-}
557
+	if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
558
+			$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
559
+	}
560
+	}
527 561
 
528 562
 /*
529 563
  * Injection par connect
@@ -572,8 +606,9 @@  discard block
 block discarded – undo
572 606
 /*
573 607
  * Bloque les bots quand le load déborde
574 608
  */
575
-if (!defined('_ECRAN_SECURITE_LOAD'))
609
+if (!defined('_ECRAN_SECURITE_LOAD')) {
576 610
 	define('_ECRAN_SECURITE_LOAD', 4);
611
+}
577 612
 
578 613
 if (
579 614
 	defined('_ECRAN_SECURITE_LOAD')
Please login to merge, or discard this patch.