Completed
Push — spip-3.0 ( 0bbd73...b24c06 )
by cam
06:45
created
ecrire/inc/filtres_mini.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		return $r[1].resolve_path($r[2]);
51 51
 
52 52
 	# L'url site spip est un lien absolu aussi
53
-	if ($lien == $GLOBALS['meta']['adresse_site']){
53
+	if ($lien == $GLOBALS['meta']['adresse_site']) {
54 54
 		return $lien;
55 55
 	}
56 56
 
@@ -60,29 +60,29 @@  discard block
 block discarded – undo
60 60
 		$debut = $regs[1];
61 61
 		$dir = !strlen($regs[2]) ? '/' : $regs[2];
62 62
 		$mot = $regs[3];
63
-		$get = isset($regs[4])?$regs[4]:"";
64
-		$hash = isset($regs[5])?$regs[5]:"";
63
+		$get = isset($regs[4]) ? $regs[4] : "";
64
+		$hash = isset($regs[5]) ? $regs[5] : "";
65 65
 	}
66
-	switch (substr($lien,0,1)) {
66
+	switch (substr($lien, 0, 1)) {
67 67
 		case '/':
68
-			return $debut . resolve_path($lien);
68
+			return $debut.resolve_path($lien);
69 69
 		case '#':
70
-			return $debut . resolve_path($dir.$mot.$get.$lien);
70
+			return $debut.resolve_path($dir.$mot.$get.$lien);
71 71
 		case '':
72
-			return $debut . resolve_path($dir.$mot.$get.$hash);
72
+			return $debut.resolve_path($dir.$mot.$get.$hash);
73 73
 		default:
74
-			return $debut . resolve_path($dir.$lien);
74
+			return $debut.resolve_path($dir.$lien);
75 75
 	}
76 76
 }
77 77
 
78 78
 // un filtre pour transformer les URLs relatives en URLs absolues ;
79 79
 // ne s'applique qu'aux #URL_XXXX
80 80
 // http://doc.spip.org/@url_absolue
81
-function url_absolue($url, $base='') {
81
+function url_absolue($url, $base = '') {
82 82
 	if (strlen($url = trim($url)) == 0)
83 83
 		return '';
84 84
 	if (!$base)
85
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
85
+		$base = url_de_base().(_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
86 86
 	return suivre_lien($base, $url);
87 87
 }
88 88
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
  * @param string $url_absolue
93 93
  * @return string
94 94
  */
95
-function protocole_implicite($url_absolue){
96
-	return preg_replace(";^[a-z]{3,7}://;i","//",$url_absolue);
95
+function protocole_implicite($url_absolue) {
96
+	return preg_replace(";^[a-z]{3,7}://;i", "//", $url_absolue);
97 97
 }
98 98
 
99 99
 /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
  * @param array $protocoles_autorises
103 103
  * @return bool
104 104
  */
105
-function protocole_verifier($url_absolue, $protocoles_autorises = array('http','https')) {
105
+function protocole_verifier($url_absolue, $protocoles_autorises = array('http', 'https')) {
106 106
 
107 107
 	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
108 108
 		$protocole = $m[1];
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
 // un filtre pour transformer les URLs relatives en URLs absolues ;
118 118
 // ne s'applique qu'aux textes contenant des liens
119 119
 // http://doc.spip.org/@liens_absolus
120
-function liens_absolus($texte, $base='') {
120
+function liens_absolus($texte, $base = '') {
121 121
 	if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', 
122 122
 	$texte, $liens, PREG_SET_ORDER)) {
123 123
 		if (!function_exists('extraire_attribut')) {
124 124
 			include_spip('inc/filtres');
125 125
 		}
126 126
 		foreach ($liens as $lien) {
127
-			foreach(array('href', 'src') as $attr) {
127
+			foreach (array('href', 'src') as $attr) {
128 128
 				$href = extraire_attribut($lien[0], $attr);
129
-				if (strlen($href)>0) {
129
+				if (strlen($href) > 0) {
130 130
 					$abs = url_absolue($href, $base);
131
-					if ($href != $abs and !preg_match('/^#/',$href)) {
131
+					if ($href != $abs and !preg_match('/^#/', $href)) {
132 132
 						$texte_lien = inserer_attribut($lien[0], $attr, $abs);
133
-						$texte = str_replace($lien[0],$texte_lien,$texte);
133
+						$texte = str_replace($lien[0], $texte_lien, $texte);
134 134
 					}
135 135
 				}
136 136
 			}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 // Ce filtre public va traiter les URL ou les <a href>
145 145
 //
146 146
 // http://doc.spip.org/@abs_url
147
-function abs_url($texte, $base='') {
147
+function abs_url($texte, $base = '') {
148 148
 	if ($GLOBALS['mode_abs_url'] == 'url')
149 149
 		return url_absolue($texte, $base);
150 150
 	else
@@ -160,18 +160,18 @@  discard block
 block discarded – undo
160 160
 * @param bool $double_encode
161 161
 * @return string
162 162
 */
163
-function spip_htmlspecialchars($string, $flags=null, $encoding='ISO-8859-1', $double_encode = true){
163
+function spip_htmlspecialchars($string, $flags = null, $encoding = 'ISO-8859-1', $double_encode = true) {
164 164
 	if (is_null($flags)) {
165 165
 		if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50400)
166 166
 			$flags = ENT_COMPAT;
167 167
 		else
168
-			$flags = ENT_COMPAT|ENT_HTML401;
168
+			$flags = ENT_COMPAT | ENT_HTML401;
169 169
 	}
170 170
 
171 171
 	if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50203)
172
-		return htmlspecialchars($string,$flags,$encoding);
172
+		return htmlspecialchars($string, $flags, $encoding);
173 173
 	else
174
-		return htmlspecialchars($string,$flags,$encoding,$double_encode);
174
+		return htmlspecialchars($string, $flags, $encoding, $double_encode);
175 175
 }
176 176
 
177 177
 /**
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 * @param bool $double_encode
184 184
 * @return string
185 185
 */
186
-function spip_htmlentities($string,$flags=null,$encoding = 'ISO-8859-1',$double_encode = true){
186
+function spip_htmlentities($string, $flags = null, $encoding = 'ISO-8859-1', $double_encode = true) {
187 187
 	if (is_null($flags)) {
188 188
 		if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50400)
189 189
 			$flags = ENT_COMPAT;
190 190
 		else
191
-			$flags = ENT_COMPAT|ENT_HTML401;
191
+			$flags = ENT_COMPAT | ENT_HTML401;
192 192
 	}
193 193
 
194 194
 	if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50203)
195
-		return htmlentities($string,$flags,$encoding);
195
+		return htmlentities($string, $flags, $encoding);
196 196
 	else
197
-		return htmlentities($string,$flags,$encoding,$double_encode);
197
+		return htmlentities($string, $flags, $encoding, $double_encode);
198 198
 }
199 199
 ?>
Please login to merge, or discard this patch.
ecrire/inc/distant.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 
20 20
 if (!defined('_INC_DISTANT_VERSION_HTTP')) define('_INC_DISTANT_VERSION_HTTP', "HTTP/1.0");
21 21
 if (!defined('_INC_DISTANT_CONTENT_ENCODING')) define('_INC_DISTANT_CONTENT_ENCODING', "gzip");
22
-if (!defined('_INC_DISTANT_USER_AGENT')) define('_INC_DISTANT_USER_AGENT', 'SPIP-' . $GLOBALS['spip_version_affichee'] . " (" . $GLOBALS['home_server'] . ")");
23
-if (!defined('_INC_DISTANT_MAX_SIZE')) define('_INC_DISTANT_MAX_SIZE',2097152);
24
-if (!defined('_INC_DISTANT_CONNECT_TIMEOUT')) define('_INC_DISTANT_CONNECT_TIMEOUT',10);
22
+if (!defined('_INC_DISTANT_USER_AGENT')) define('_INC_DISTANT_USER_AGENT', 'SPIP-'.$GLOBALS['spip_version_affichee']." (".$GLOBALS['home_server'].")");
23
+if (!defined('_INC_DISTANT_MAX_SIZE')) define('_INC_DISTANT_MAX_SIZE', 2097152);
24
+if (!defined('_INC_DISTANT_CONNECT_TIMEOUT')) define('_INC_DISTANT_CONNECT_TIMEOUT', 10);
25 25
 
26
-define('_REGEXP_COPIE_LOCALE', ',' .
26
+define('_REGEXP_COPIE_LOCALE', ','.
27 27
        preg_replace('@^https?:@', 'https?:', $GLOBALS['meta']['adresse_site'])
28 28
        . "/?spip.php[?]action=acceder_document.*file=(.*)$,");
29 29
 
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
  *   taille maxi de la copie local, par defaut _COPIE_LOCALE_MAX_SIZE
50 50
  * @return bool|string
51 51
  */
52
-function copie_locale($source, $mode='auto', $local=null, $taille_max=null){
52
+function copie_locale($source, $mode = 'auto', $local = null, $taille_max = null) {
53 53
 
54 54
 	// si c'est la protection de soi-meme, retourner le path
55 55
 	if ($mode !== 'force' AND preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) {
56
-		$source = substr(_DIR_IMG,strlen(_DIR_RACINE)) . urldecode($match[1]);
56
+		$source = substr(_DIR_IMG, strlen(_DIR_RACINE)).urldecode($match[1]);
57 57
 		return @file_exists($source) ? $source : false;
58 58
 	}
59 59
 
60 60
 	if (is_null($local))
61 61
 		$local = fichier_copie_locale($source);
62 62
 	else {
63
-		if (_DIR_RACINE AND strncmp(_DIR_RACINE, $local, strlen(_DIR_RACINE))==0) {
63
+		if (_DIR_RACINE AND strncmp(_DIR_RACINE, $local, strlen(_DIR_RACINE)) == 0) {
64 64
 			$local = substr($local, strlen(_DIR_RACINE));
65 65
 		}
66 66
 	}
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 	if (!$local) return false;
72 72
 
73 73
 	$localrac = _DIR_RACINE.$local;
74
-	$t = ($mode=='force') ? false  : @file_exists($localrac);
74
+	$t = ($mode == 'force') ? false  : @file_exists($localrac);
75 75
 
76 76
 	// test d'existence du fichier
77
-	if ($mode=='test') return $t ? $local : '';
77
+	if ($mode == 'test') return $t ? $local : '';
78 78
 
79 79
 	// sinon voir si on doit/peut le telecharger
80
-	if ($local==$source OR !preg_match(',^\w+://,', $source))
80
+	if ($local == $source OR !preg_match(',^\w+://,', $source))
81 81
 		return $local;
82 82
 
83
-	if ($mode=='modif' OR !$t){
83
+	if ($mode == 'modif' OR !$t) {
84 84
 		// passer par un fichier temporaire unique pour gerer les echecs en cours de recuperation
85 85
 		// et des eventuelles recuperations concurantes
86 86
 		include_spip("inc/acces");
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		$res = recuperer_page($source, $localrac, false, $taille_max, '', '', false, $t ? filemtime($localrac) : '');
89 89
 		if (!$res) {
90 90
 			if (!$t) // si $t c'est sans doute juste un not-modified-since qui fait renvoyer false
91
-				spip_log("copie_locale : Echec recuperation $source sur $localrac",_LOG_INFO_IMPORTANTE);
91
+				spip_log("copie_locale : Echec recuperation $source sur $localrac", _LOG_INFO_IMPORTANTE);
92 92
 			return $t ? $local : false;
93 93
 		}
94 94
 		spip_log("copie_locale : recuperation $source sur $localrac taille $res OK");
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
  *   url ou false en cas d'echec
122 122
  */
123 123
 function valider_url_distante($url, $known_hosts = array()) {
124
-	if (!function_exists('protocole_verifier')){
124
+	if (!function_exists('protocole_verifier')) {
125 125
 		include_spip('inc/filtres_mini');
126 126
 	}
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 	
132 132
 	$parsed_url = parse_url($url);
133
-	if (!$parsed_url or empty($parsed_url['host']) ) {
133
+	if (!$parsed_url or empty($parsed_url['host'])) {
134 134
 		return false;
135 135
 	}
136 136
 
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 			}
172 172
 		}
173 173
 		if ($ip) {
174
-			$parts = array_map('intval', explode( '.', $ip ));
174
+			$parts = array_map('intval', explode('.', $ip));
175 175
 			if (127 === $parts[0] or 10 === $parts[0] or 0 === $parts[0]
176
-			  or ( 172 === $parts[0] and 16 <= $parts[1] and 31 >= $parts[1] )
177
-			  or ( 192 === $parts[0] && 168 === $parts[1] )
176
+			  or (172 === $parts[0] and 16 <= $parts[1] and 31 >= $parts[1])
177
+			  or (192 === $parts[0] && 168 === $parts[1])
178 178
 			) {
179 179
 				return false;
180 180
 			}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 
188 188
 	$port = $parsed_url['port'];
189
-	if ($port === 80  or $port === 443  or $port === 8080) {
189
+	if ($port === 80 or $port === 443 or $port === 8080) {
190 190
 		return $url;
191 191
 	}
192 192
 
@@ -212,27 +212,27 @@  discard block
 block discarded – undo
212 212
 	// pour un appel soap par exemple
213 213
 	// l'entete est separe des donnees par un double retour a la ligne
214 214
 	// on s'occupe ici de passer tous les retours lignes (\r\n, \r ou \n) en \r\n
215
-	if (is_string($donnees) && strlen($donnees)){
215
+	if (is_string($donnees) && strlen($donnees)) {
216 216
 		$entete = "";
217 217
 		// on repasse tous les \r\n et \r en simples \n
218
-		$donnees = str_replace("\r\n","\n",$donnees);
219
-		$donnees = str_replace("\r","\n",$donnees);
218
+		$donnees = str_replace("\r\n", "\n", $donnees);
219
+		$donnees = str_replace("\r", "\n", $donnees);
220 220
 		// un double retour a la ligne signifie la fin de l'entete et le debut des donnees
221 221
 		$p = strpos($donnees, "\n\n");
222
-		if ($p!==FALSE){
223
-			$entete = str_replace("\n", "\r\n", substr($donnees, 0, $p+1));
224
-			$donnees = substr($donnees, $p+2);
222
+		if ($p !== FALSE) {
223
+			$entete = str_replace("\n", "\r\n", substr($donnees, 0, $p + 1));
224
+			$donnees = substr($donnees, $p + 2);
225 225
 		}
226 226
 		$chaine = str_replace("\n", "\r\n", $donnees);
227 227
 	}
228 228
 	else {
229 229
 		/* boundary automatique */
230 230
 		// Si on a plus de 500 octects de donnees, on "boundarise"
231
-		if ($boundary===''){
231
+		if ($boundary === '') {
232 232
 			$taille = 0;
233
-			foreach ($donnees as $cle => $valeur){
234
-				if (is_array($valeur)){
235
-					foreach ($valeur as $val2){
233
+			foreach ($donnees as $cle => $valeur) {
234
+				if (is_array($valeur)) {
235
+					foreach ($valeur as $val2) {
236 236
 						$taille += strlen($val2);
237 237
 					}
238 238
 				} else {
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 					$taille += strlen($valeur);
241 241
 				}
242 242
 			}
243
-			if ($taille>500){
244
-				$boundary = substr(md5(rand() . 'spip'), 0, 8);
243
+			if ($taille > 500) {
244
+				$boundary = substr(md5(rand().'spip'), 0, 8);
245 245
 			}
246 246
 		}
247 247
 
248
-		if (is_string($boundary) and strlen($boundary)){
248
+		if (is_string($boundary) and strlen($boundary)) {
249 249
 			// fabrique une chaine HTTP pour un POST avec boundary
250 250
 			$entete = "Content-Type: multipart/form-data; boundary=$boundary\r\n";
251 251
 			$chaine = '';
@@ -334,21 +334,21 @@  discard block
 block discarded – undo
334 334
 // http://doc.spip.org/@recuperer_page
335 335
 function recuperer_page($url, $trans = false, $get_headers = false,
336 336
                         $taille_max = null, $datas = '', $boundary = '', $refuser_gz = false,
337
-                        $date_verif = '', $uri_referer = ''){
337
+                        $date_verif = '', $uri_referer = '') {
338 338
 	$gz = false;
339 339
 
340 340
 	// $copy = copier le fichier ?
341
-	$copy = (is_string($trans) AND strlen($trans)>5); // eviter "false" :-)
341
+	$copy = (is_string($trans) AND strlen($trans) > 5); // eviter "false" :-)
342 342
 
343 343
 	if (is_null($taille_max))
344 344
 		$taille_max = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE;
345 345
 
346 346
 	// Accepter les URLs au format feed:// ou qui ont oublie le http://
347 347
 	$url = preg_replace(',^feed://,i', 'http://', $url);
348
-	if (!preg_match(',^[a-z]+://,i', $url)) $url = 'http://' . $url;
348
+	if (!preg_match(',^[a-z]+://,i', $url)) $url = 'http://'.$url;
349 349
 	$url = url_to_ascii($url);
350 350
 
351
-	if ($taille_max==0)
351
+	if ($taille_max == 0)
352 352
 		$get = 'HEAD';
353 353
 	else
354 354
 		$get = 'GET';
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 	if (!empty($datas)) {
357 357
 		$get = 'POST';
358 358
 		list($type, $postdata) = prepare_donnees_post($datas, $boundary);
359
-		$datas = $type . 'Content-Length: ' . strlen($postdata) . "\r\n\r\n" . $postdata;
359
+		$datas = $type.'Content-Length: '.strlen($postdata)."\r\n\r\n".$postdata;
360 360
 	}
361 361
 
362 362
 	// dix tentatives maximum en cas d'entetes 301...
363
-	for ($i = 0; $i<10; $i++){
363
+	for ($i = 0; $i < 10; $i++) {
364 364
 		$url = recuperer_lapage($url, $trans, $get, $taille_max, $datas, $refuser_gz, $date_verif, $uri_referer);
365 365
 		if (!$url) return false;
366
-		if (is_array($url)){
366
+		if (is_array($url)) {
367 367
 			list($headers, $result) = $url;
368
-			return ($get_headers ? $headers . "\n" : '') . $result;
368
+			return ($get_headers ? $headers."\n" : '').$result;
369 369
 		} else spip_log("recuperer page recommence sur $url");
370 370
 	}
371 371
 }
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
 // si $trans est null -> on ne veut que les headers
376 376
 // si $trans est une chaine, c'est un nom de fichier pour ecrire directement dedans
377 377
 // http://doc.spip.org/@recuperer_lapage
378
-function recuperer_lapage($url, $trans = false, $get = 'GET', $taille_max = _INC_DISTANT_MAX_SIZE, $datas = '', $refuser_gz = false, $date_verif = '', $uri_referer = ''){
378
+function recuperer_lapage($url, $trans = false, $get = 'GET', $taille_max = _INC_DISTANT_MAX_SIZE, $datas = '', $refuser_gz = false, $date_verif = '', $uri_referer = '') {
379 379
 	// $copy = copier le fichier ?
380
-	$copy = (is_string($trans) AND strlen($trans)>5); // eviter "false" :-)
380
+	$copy = (is_string($trans) AND strlen($trans) > 5); // eviter "false" :-)
381 381
 
382 382
 	// si on ecrit directement dans un fichier, pour ne pas manipuler
383 383
 	// en memoire refuser gz
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
 	// ouvrir la connexion et envoyer la requete et ses en-tetes
388 388
 	list($f, $fopen) = init_http($get, $url, $refuser_gz, $uri_referer, $datas, _INC_DISTANT_VERSION_HTTP, $date_verif);
389
-	if (!$f){
389
+	if (!$f) {
390 390
 		spip_log("ECHEC init_http $url");
391 391
 		return false;
392 392
 	}
@@ -398,25 +398,25 @@  discard block
 block discarded – undo
398 398
 		$headers = '';
399 399
 	else {
400 400
 		$headers = recuperer_entetes($f, $date_verif);
401
-		if (is_numeric($headers)){
401
+		if (is_numeric($headers)) {
402 402
 			fclose($f);
403 403
 			// Chinoisierie inexplicable pour contrer
404 404
 			// les actions liberticides de l'empire du milieu
405
-			if ($headers){
405
+			if ($headers) {
406 406
 				spip_log("HTTP status $headers pour $url");
407 407
 				return false;
408 408
 			}
409 409
 			$t = @parse_url($url);
410 410
 			$host = $t['host'];
411 411
 			if (!need_proxy($host)
412
-				AND $result = @file_get_contents($url)){
412
+				AND $result = @file_get_contents($url)) {
413 413
 				// on peuple les headers de vide et on continue
414 414
 				$headers = array('');
415 415
 			}
416 416
 			else
417 417
 				return false;
418 418
 		}
419
-		if (!is_array($headers)){ // cas Location
419
+		if (!is_array($headers)) { // cas Location
420 420
 			fclose($f);
421 421
 			include_spip('inc/filtres');
422 422
 			return suivre_lien($url, $headers);
@@ -424,16 +424,16 @@  discard block
 block discarded – undo
424 424
 		$headers = join('', $headers);
425 425
 	}
426 426
 
427
-	if ($trans===NULL) return array($headers, '');
427
+	if ($trans === NULL) return array($headers, '');
428 428
 
429 429
 	// s'il faut deballer, le faire via un fichier temporaire
430 430
 	// sinon la memoire explose pour les gros flux
431 431
 
432 432
 	$gz = preg_match(",\bContent-Encoding: .*gzip,is", $headers) ?
433
-		(_DIR_TMP . md5(uniqid(mt_rand())) . '.tmp.gz') : '';
433
+		(_DIR_TMP.md5(uniqid(mt_rand())).'.tmp.gz') : '';
434 434
 
435 435
 #	spip_log("entete ($trans $copy $gz)\n$headers");
436
-	if (!$result){
436
+	if (!$result) {
437 437
 		$result = recuperer_body($f, $taille_max, $gz ? $gz : ($copy ? $trans : ''));
438 438
 		fclose($f);
439 439
 	}
@@ -441,12 +441,12 @@  discard block
 block discarded – undo
441 441
 		return array($headers, $result);
442 442
 
443 443
 	// Decompresser au besoin
444
-	if ($gz){
444
+	if ($gz) {
445 445
 		$result = join('', gzfile($gz));
446 446
 		supprimer_fichier($gz);
447 447
 	}
448 448
 	// Faut-il l'importer dans notre charset local ?
449
-	if ($trans===true){
449
+	if ($trans === true) {
450 450
 		include_spip('inc/charsets');
451 451
 		$result = transcoder_page($result, $headers);
452 452
 	}
@@ -455,32 +455,32 @@  discard block
 block discarded – undo
455 455
 }
456 456
 
457 457
 // http://doc.spip.org/@recuperer_body
458
-function recuperer_body($f, $taille_max = _INC_DISTANT_MAX_SIZE, $fichier = ''){
458
+function recuperer_body($f, $taille_max = _INC_DISTANT_MAX_SIZE, $fichier = '') {
459 459
 	$taille = 0;
460 460
 	$result = '';
461 461
 	$fp = false;
462
-	if ($fichier){
462
+	if ($fichier) {
463 463
 		include_spip("inc/acces");
464 464
 		$tmpfile = "$fichier.".creer_uniqid().".tmp";
465 465
 		$fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX);
466
-		if (!$fp AND file_exists($fichier)){
466
+		if (!$fp AND file_exists($fichier)) {
467 467
 			return filesize($fichier);
468 468
 		}
469 469
 		if (!$fp)
470 470
 			return false;
471 471
 		$result = 0; // on renvoie la taille du fichier
472 472
 	}
473
-	while (!feof($f) AND $taille<$taille_max){
473
+	while (!feof($f) AND $taille < $taille_max) {
474 474
 		$res = fread($f, 16384);
475 475
 		$taille += strlen($res);
476
-		if ($fp){
476
+		if ($fp) {
477 477
 			fwrite($fp, $res);
478 478
 			$result = $taille;
479 479
 		}
480 480
 		else
481 481
 			$result .= $res;
482 482
 	}
483
-	if ($fp){
483
+	if ($fp) {
484 484
 		spip_fclose_unlock($fp);
485 485
 		spip_unlink($fichier);
486 486
 		@rename($tmpfile, $fichier);
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
 // le tableau des entetes dans tous les autres cas
497 497
 
498 498
 // http://doc.spip.org/@recuperer_entetes
499
-function recuperer_entetes($f, $date_verif = ''){
499
+function recuperer_entetes($f, $date_verif = '') {
500 500
 	$s = @trim(fgets($f, 16384));
501 501
 
502
-	if (!preg_match(',^HTTP/[0-9]+\.[0-9]+ ([0-9]+),', $s, $r)){
502
+	if (!preg_match(',^HTTP/[0-9]+\.[0-9]+ ([0-9]+),', $s, $r)) {
503 503
 		return 0;
504 504
 	}
505 505
 	$status = intval($r[1]);
506 506
 	$headers = array();
507 507
 	$not_modif = $location = false;
508
-	while ($s = trim(fgets($f, 16384))){
509
-		$headers[] = $s . "\n";
508
+	while ($s = trim(fgets($f, 16384))) {
509
+		$headers[] = $s."\n";
510 510
 		preg_match(',^([^:]*): *(.*)$,i', $s, $r);
511 511
 		list(, $d, $v) = $r;
512
-		if (strtolower(trim($d))=='location' AND $status>=300 AND $status<400){
512
+		if (strtolower(trim($d)) == 'location' AND $status >= 300 AND $status < 400) {
513 513
 			$location = $v;
514 514
 		}
515
-		elseif ($date_verif AND ($d=='Last-Modified')) {
516
-			if ($date_verif>=strtotime($v)){
515
+		elseif ($date_verif AND ($d == 'Last-Modified')) {
516
+			if ($date_verif >= strtotime($v)) {
517 517
 				//Cas ou la page distante n'a pas bouge depuis
518 518
 				//la derniere visite
519 519
 				$not_modif = true;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
 	if ($location)
525 525
 		return $location;
526
-	if ($status!=200 or $not_modif)
526
+	if ($status != 200 or $not_modif)
527 527
 		return $status;
528 528
 	return $headers;
529 529
 }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 // mais la tout de suite je ne trouve pas l'idee, etant donne les limitations
534 534
 // des filesystems
535 535
 // http://doc.spip.org/@nom_fichier_copie_locale
536
-function nom_fichier_copie_locale($source, $extension){
536
+function nom_fichier_copie_locale($source, $extension) {
537 537
 	include_spip('inc/documents');
538 538
 
539 539
 	$d = creer_repertoire_documents('distant'); # IMG/distant/
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
 
542 542
 	// on se place tout le temps comme si on etait a la racine
543 543
 	if (_DIR_RACINE)
544
-		$d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d);
544
+		$d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d);
545 545
 
546 546
 	$m = md5($source);
547 547
 
548 548
 	return $d
549
-		. substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12)
549
+		. substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12)
550 550
 		. substr($m, 0, 4)
551 551
 		. ".$extension";
552 552
 }
@@ -555,11 +555,11 @@  discard block
 block discarded – undo
555 555
 // Donne le nom de la copie locale de la source
556 556
 //
557 557
 // http://doc.spip.org/@fichier_copie_locale
558
-function fichier_copie_locale($source){
558
+function fichier_copie_locale($source) {
559 559
 	// Si c'est deja local pas de souci
560
-	if (!preg_match(',^\w+://,', $source)){
560
+	if (!preg_match(',^\w+://,', $source)) {
561 561
 		if (_DIR_RACINE)
562
-			$source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source);
562
+			$source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source);
563 563
 		return $source;
564 564
 	}
565 565
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	if ($ext
572 572
 	AND preg_match(',^\w+$,', $ext) // pas de php?truc=1&...
573 573
 	AND $f = nom_fichier_copie_locale($source, $ext)
574
-	AND file_exists(_DIR_RACINE . $f)
574
+	AND file_exists(_DIR_RACINE.$f)
575 575
 	)
576 576
 		return $f;
577 577
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	// Si c'est deja dans la table des documents,
580 580
 	// ramener le nom de sa copie potentielle
581 581
 
582
-	$ext = sql_getfetsel("extension", "spip_documents", "fichier=" . sql_quote($source) . " AND distant='oui' AND extension <> ''");
582
+	$ext = sql_getfetsel("extension", "spip_documents", "fichier=".sql_quote($source)." AND distant='oui' AND extension <> ''");
583 583
 
584 584
 
585 585
 	if ($ext) return nom_fichier_copie_locale($source, $ext);
@@ -589,25 +589,25 @@  discard block
 block discarded – undo
589 589
 
590 590
 	$ext = $path_parts ? $path_parts['extension'] : '';
591 591
 
592
-	if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=" . sql_quote($ext))){
592
+	if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) {
593 593
 		$f = nom_fichier_copie_locale($source, $ext);
594
-		if (file_exists(_DIR_RACINE . $f))
594
+		if (file_exists(_DIR_RACINE.$f))
595 595
 			return $f;
596 596
 	}
597 597
 
598 598
 	// Ping  pour voir si son extension est connue et autorisee
599 599
 	// avec mise en cache du resultat du ping
600 600
 
601
-	$cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source);
601
+	$cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source);
602 602
 	if (!@file_exists($cache)
603 603
 		OR !$path_parts = @unserialize(spip_file_get_contents($cache))
604
-		OR _request('var_mode')=='recalcul'
605
-	){
604
+		OR _request('var_mode') == 'recalcul'
605
+	) {
606 606
 		$path_parts = recuperer_infos_distantes($source, 0, false);
607 607
 		ecrire_fichier($cache, serialize($path_parts));
608 608
 	}
609 609
 	$ext = $path_parts ? $path_parts['extension'] : '';
610
-	if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=" . sql_quote($ext))){
610
+	if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) {
611 611
 		return nom_fichier_copie_locale($source, $ext);
612 612
 	}
613 613
 	spip_log("pas de copie locale pour $source");
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 #$a['mime_type'] = chaine
627 627
 
628 628
 // http://doc.spip.org/@recuperer_infos_distantes
629
-function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = true){
629
+function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = true) {
630 630
 
631 631
 	// pas la peine de perdre son temps
632 632
 	if (!tester_url_absolue($source)) {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	// On va directement charger le debut des images et des fichiers html,
643 643
 	// de maniere a attrapper le maximum d'infos (titre, taille, etc). Si
644 644
 	// ca echoue l'utilisateur devra les entrer...
645
-	if ($headers = recuperer_page($source, false, true, $max, '', '', true)){
645
+	if ($headers = recuperer_page($source, false, true, $max, '', '', true)) {
646 646
 		list($headers, $a['body']) = preg_split(',\n\n,', $headers, 2);
647 647
 
648 648
 		if (preg_match(",\nContent-Type: *([^[:space:];]*),i", "\n$headers", $regs))
@@ -660,36 +660,36 @@  discard block
 block discarded – undo
660 660
 		// ce qu'il sert ; on va tenter de detecter via l'extension de l'url
661 661
 		// ou le Content-Disposition: attachment; filename=...
662 662
 		$t = null;
663
-		if (in_array($mime_type, array('text/plain', '', 'application/octet-stream'))){
663
+		if (in_array($mime_type, array('text/plain', '', 'application/octet-stream'))) {
664 664
 			if (!$t
665 665
 				AND preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
666
-			){
667
-				$t = sql_fetsel("extension", "spip_types_documents", "extension=" . sql_quote($rext[1],'','text'));
666
+			) {
667
+				$t = sql_fetsel("extension", "spip_types_documents", "extension=".sql_quote($rext[1], '', 'text'));
668 668
 			}
669 669
 			if (!$t
670 670
 				AND preg_match(",^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims", $headers, $m)
671 671
 				AND preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext)
672
-			){
673
-				$t = sql_fetsel("extension", "spip_types_documents", "extension=" . sql_quote($rext[1],'','text'));
672
+			) {
673
+				$t = sql_fetsel("extension", "spip_types_documents", "extension=".sql_quote($rext[1], '', 'text'));
674 674
 			}
675 675
 		}
676 676
 
677 677
 		// Autre mime/type (ou text/plain avec fichier d'extension inconnue)
678 678
 		if (!$t)
679
-			$t = sql_fetsel("extension", "spip_types_documents", "mime_type=" . sql_quote($mime_type));
679
+			$t = sql_fetsel("extension", "spip_types_documents", "mime_type=".sql_quote($mime_type));
680 680
 
681 681
 		// Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg)
682 682
 		// On essaie de nouveau avec l'extension
683 683
 		if (!$t
684
-			AND $mime_type!='text/plain'
684
+			AND $mime_type != 'text/plain'
685 685
 			AND preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
686
-		){
687
-			$t = sql_fetsel("extension", "spip_types_documents", "extension=" . sql_quote($rext[1],'','text')); # eviter xxx.3 => 3gp (> SPIP 3)
686
+		) {
687
+			$t = sql_fetsel("extension", "spip_types_documents", "extension=".sql_quote($rext[1], '', 'text')); # eviter xxx.3 => 3gp (> SPIP 3)
688 688
 		}
689 689
 
690 690
 
691
-		if ($t){
692
-			spip_log("mime-type $mime_type ok, extension " . $t['extension']);
691
+		if ($t) {
692
+			spip_log("mime-type $mime_type ok, extension ".$t['extension']);
693 693
 			$a['extension'] = $t['extension'];
694 694
 		} else {
695 695
 			# par defaut on retombe sur '.bin' si c'est autorise
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	}
707 707
 
708 708
 	// Echec avec HEAD, on tente avec GET
709
-	if (!$a AND !$max){
709
+	if (!$a AND !$max) {
710 710
 		spip_log("tenter GET $source");
711 711
 		$a = recuperer_infos_distantes($source, _INC_DISTANT_MAX_SIZE);
712 712
 	}
@@ -718,16 +718,16 @@  discard block
 block discarded – undo
718 718
 
719 719
 	// S'il s'agit d'une image pas trop grosse ou d'un fichier html, on va aller
720 720
 	// recharger le document en GET et recuperer des donnees supplementaires...
721
-	if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)){
722
-		if ($max==0
723
-			AND $a['taille']<_INC_DISTANT_MAX_SIZE
724
-				AND (strpos($GLOBALS['meta']['formats_graphiques'], $a['extension'])!==false)
721
+	if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)) {
722
+		if ($max == 0
723
+			AND $a['taille'] < _INC_DISTANT_MAX_SIZE
724
+				AND (strpos($GLOBALS['meta']['formats_graphiques'], $a['extension']) !== false)
725 725
 					AND $charger_si_petite_image
726
-		){
726
+		) {
727 727
 			$a = recuperer_infos_distantes($source, _INC_DISTANT_MAX_SIZE);
728 728
 		}
729
-		else if ($a['body']){
730
-			$a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $a['extension']);
729
+		else if ($a['body']) {
730
+			$a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $a['extension']);
731 731
 			ecrire_fichier($a['fichier'], $a['body']);
732 732
 			$size_image = @getimagesize($a['fichier']);
733 733
 			$a['largeur'] = intval($size_image[0]);
@@ -738,21 +738,21 @@  discard block
 block discarded – undo
738 738
 
739 739
 	// Fichier swf, si on n'a pas la taille, on va mettre 425x350 par defaut
740 740
 	// ce sera mieux que 0x0
741
-	if ($a AND $a['extension']=='swf'
741
+	if ($a AND $a['extension'] == 'swf'
742 742
 		AND !$a['largeur']
743
-	){
743
+	) {
744 744
 		$a['largeur'] = 425;
745 745
 		$a['hauteur'] = 350;
746 746
 	}
747 747
 
748
-	if ($mime_type=='text/html'){
748
+	if ($mime_type == 'text/html') {
749 749
 		include_spip('inc/filtres');
750 750
 		$page = recuperer_page($source, true, false, _INC_DISTANT_MAX_SIZE);
751 751
 		if (preg_match(',<title>(.*?)</title>,ims', $page, $regs))
752 752
 			$a['titre'] = corriger_caracteres(trim($regs[1]));
753 753
 		if (!$a['taille']) $a['taille'] = strlen($page); # a peu pres
754 754
 	}
755
-	$a['mime_type']=$mime_type;
755
+	$a['mime_type'] = $mime_type;
756 756
 
757 757
 	return $a;
758 758
 }
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
  * @param string $http_noproxy
769 769
  * @return string
770 770
  */
771
-function need_proxy($host, $http_proxy = null, $http_noproxy = null){
771
+function need_proxy($host, $http_proxy = null, $http_noproxy = null) {
772 772
 	if (is_null($http_proxy))
773 773
 		$http_proxy = @$GLOBALS['meta']["http_proxy"];
774 774
 	if (is_null($http_noproxy))
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	$domain = substr($host, strpos($host, '.'));
778 778
 
779 779
 	return ($http_proxy
780
-		AND (strpos(" $http_noproxy ", " $host ")===false
781
-		AND (strpos(" $http_noproxy ", " $domain ")===false)))
780
+		AND (strpos(" $http_noproxy ", " $host ") === false
781
+		AND (strpos(" $http_noproxy ", " $domain ") === false)))
782 782
 		? $http_proxy : '';
783 783
 }
784 784
 
@@ -787,37 +787,37 @@  discard block
 block discarded – undo
787 787
 // retourne le descripteur sur lequel lire la reponse
788 788
 //
789 789
 // http://doc.spip.org/@init_http
790
-function init_http($method, $url, $refuse_gz = false, $referer = '', $datas = "", $vers = "HTTP/1.0", $date = ''){
790
+function init_http($method, $url, $refuse_gz = false, $referer = '', $datas = "", $vers = "HTTP/1.0", $date = '') {
791 791
 	$user = $via_proxy = $proxy_user = '';
792 792
 	$fopen = false;
793 793
 
794 794
 	$t = @parse_url($url);
795 795
 	$host = $t['host'];
796
-	if ($t['scheme']=='http'){
796
+	if ($t['scheme'] == 'http') {
797 797
 		$scheme = 'http';
798 798
 		$noproxy = '';
799
-	} elseif ($t['scheme']=='https') {
799
+	} elseif ($t['scheme'] == 'https') {
800 800
 		$scheme = 'ssl';
801 801
 		$noproxy = 'ssl://';
802 802
 		if (!isset($t['port']) || !($port = $t['port'])) $t['port'] = 443;
803 803
 	}
804 804
 	else {
805 805
 		$scheme = $t['scheme'];
806
-		$noproxy = $scheme . '://';
806
+		$noproxy = $scheme.'://';
807 807
 	}
808 808
 	if (isset($t['user']))
809 809
 		$user = array($t['user'], $t['pass']);
810 810
 
811 811
 	if (!isset($t['port']) || !($port = $t['port'])) $port = 80;
812 812
 	if (!isset($t['path']) || !($path = $t['path'])) $path = "/";
813
-	if (@$t['query']) $path .= "?" . $t['query'];
813
+	if (@$t['query']) $path .= "?".$t['query'];
814 814
 
815 815
 	$f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date);
816
-	if (!$f){
816
+	if (!$f) {
817 817
 		// fallback : fopen
818 818
 		if (!need_proxy($host)
819 819
 		  AND !_request('tester_proxy')
820
-		  AND (!isset($GLOBALS['inc_distant_allow_fopen']) OR $GLOBALS['inc_distant_allow_fopen'])){
820
+		  AND (!isset($GLOBALS['inc_distant_allow_fopen']) OR $GLOBALS['inc_distant_allow_fopen'])) {
821 821
 			$f = @fopen($url, "rb");
822 822
 			spip_log("connexion vers $url par simple fopen");
823 823
 			$fopen = true;
@@ -831,37 +831,37 @@  discard block
 block discarded – undo
831 831
 }
832 832
 
833 833
 // http://doc.spip.org/@lance_requete
834
-function lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz = false, $referer = '', $datas = "", $vers = "HTTP/1.0", $date = ''){
834
+function lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz = false, $referer = '', $datas = "", $vers = "HTTP/1.0", $date = '') {
835 835
 
836 836
 	$proxy_user = '';
837 837
 	$http_proxy = need_proxy($host);
838
-	if ($user) $user = urlencode($user[0]) . ":" . urlencode($user[1]);
838
+	if ($user) $user = urlencode($user[0]).":".urlencode($user[1]);
839 839
 
840 840
 	$connect = '';
841 841
 	if ($http_proxy) {
842
-		if (defined('_PROXY_HTTPS_VIA_CONNECT') and in_array($scheme , array('tls','ssl'))) {
843
-			$path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : '');
844
-			$connect = 'CONNECT ' . $path_host . " $vers\r\n"
842
+		if (defined('_PROXY_HTTPS_VIA_CONNECT') and in_array($scheme, array('tls', 'ssl'))) {
843
+			$path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : '');
844
+			$connect = 'CONNECT '.$path_host." $vers\r\n"
845 845
 				. "Host: $path_host\r\n"
846 846
 				. "Proxy-Connection: Keep-Alive\r\n";
847 847
 		} else {
848
-			$path = (in_array($scheme , array('tls','ssl')) ? 'https://' : "$scheme://")
848
+			$path = (in_array($scheme, array('tls', 'ssl')) ? 'https://' : "$scheme://")
849 849
 				. (!$user ? '' : "$user@")
850
-				. "$host" . (($port!=80) ? ":$port" : "") . $path;
850
+				. "$host".(($port != 80) ? ":$port" : "").$path;
851 851
 		}
852 852
 		$t2 = @parse_url($http_proxy);
853 853
 		$first_host = $t2['host'];
854 854
 		if (!($port = $t2['port'])) $port = 80;
855 855
 		if ($t2['user'])
856
-			$proxy_user = base64_encode($t2['user'] . ":" . $t2['pass']);
856
+			$proxy_user = base64_encode($t2['user'].":".$t2['pass']);
857 857
 	}
858 858
 	else
859
-		$first_host = $noproxy . $host;
859
+		$first_host = $noproxy.$host;
860 860
 
861
-	if ($connect){
861
+	if ($connect) {
862 862
 		$streamContext = stream_context_create(array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true)));
863 863
 		$f = @stream_socket_client("tcp://$first_host:$port", $nError, $sError, _INC_DISTANT_CONNECT_TIMEOUT, STREAM_CLIENT_CONNECT, $streamContext);
864
-		spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)","connect");
864
+		spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", "connect");
865 865
 		if (!$f) return false;
866 866
 		stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT);
867 867
 
@@ -869,23 +869,23 @@  discard block
 block discarded – undo
869 869
 		fputs($f, "\r\n");
870 870
 		$res = fread($f, 1024);
871 871
 		if (!$res
872
-		  OR !count($res = explode(' ',$res))
873
-		  OR $res[1]!=='200'){
874
-			spip_log("Echec CONNECT sur $first_host:$port","connect"._LOG_INFO_IMPORTANTE);
872
+		  OR !count($res = explode(' ', $res))
873
+		  OR $res[1] !== '200') {
874
+			spip_log("Echec CONNECT sur $first_host:$port", "connect"._LOG_INFO_IMPORTANTE);
875 875
 			fclose($f);
876 876
 			return false;
877 877
 		}
878 878
 		// important, car sinon on lit trop vite et les donnees ne sont pas encore dispo
879 879
 		stream_set_blocking($f, true);
880 880
 		// envoyer le handshake
881
-		stream_socket_enable_crypto($f, true,	STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
882
-		spip_log("OK CONNECT sur $first_host:$port","connect");
881
+		stream_socket_enable_crypto($f, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
882
+		spip_log("OK CONNECT sur $first_host:$port", "connect");
883 883
 	}
884 884
 	else {
885 885
 		$f = @fsockopen($first_host, $port, $errno, $errstr, _INC_DISTANT_CONNECT_TIMEOUT);
886 886
 		spip_log("Recuperer $path sur $first_host:$port par $f");
887 887
 		if (!$f) {
888
-			spip_log("Erreur connexion $errno $errstr",_LOG_ERREUR);
888
+			spip_log("Erreur connexion $errno $errstr", _LOG_ERREUR);
889 889
 			return false;
890 890
 		}
891 891
 		stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT);
@@ -895,11 +895,11 @@  discard block
 block discarded – undo
895 895
 
896 896
 	$req = "$method $path $vers\r\n"
897 897
 		. "Host: $host\r\n"
898
-		. "User-Agent: " . _INC_DISTANT_USER_AGENT . "\r\n"
899
-		. ($refuse_gz ? '' : ("Accept-Encoding: " . _INC_DISTANT_CONTENT_ENCODING . "\r\n"))
898
+		. "User-Agent: "._INC_DISTANT_USER_AGENT."\r\n"
899
+		. ($refuse_gz ? '' : ("Accept-Encoding: "._INC_DISTANT_CONTENT_ENCODING."\r\n"))
900 900
 		. (!$site ? '' : "Referer: $site/$referer\r\n")
901
-		. (!$date ? '' : "If-Modified-Since: " . (gmdate("D, d M Y H:i:s", $date) . " GMT\r\n"))
902
-		. (!$user ? '' : ("Authorization: Basic " . base64_encode($user) . "\r\n"))
901
+		. (!$date ? '' : "If-Modified-Since: ".(gmdate("D, d M Y H:i:s", $date)." GMT\r\n"))
902
+		. (!$user ? '' : ("Authorization: Basic ".base64_encode($user)."\r\n"))
903 903
 		. (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n")
904 904
 		. (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n");
905 905
 
Please login to merge, or discard this patch.