Completed
Push — master ( 42b790...ca21ac )
by cam
01:43
created
ecrire/inc/distant.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	define('_INC_DISTANT_CONTENT_ENCODING', 'gzip');
27 27
 }
28 28
 if (!defined('_INC_DISTANT_USER_AGENT')) {
29
-	define('_INC_DISTANT_USER_AGENT', 'SPIP-' . $GLOBALS['spip_version_affichee'] . ' (' . $GLOBALS['home_server'] . ')');
29
+	define('_INC_DISTANT_USER_AGENT', 'SPIP-'.$GLOBALS['spip_version_affichee'].' ('.$GLOBALS['home_server'].')');
30 30
 }
31 31
 if (!defined('_INC_DISTANT_MAX_SIZE')) {
32 32
 	define('_INC_DISTANT_MAX_SIZE', 2_097_152);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	define('_INC_DISTANT_CONNECT_TIMEOUT', 10);
36 36
 }
37 37
 
38
-define('_REGEXP_COPIE_LOCALE', ',' 	.
38
+define('_REGEXP_COPIE_LOCALE', ','.
39 39
 	preg_replace(
40 40
 		'@^https?:@',
41 41
 		'https?:',
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 	// si c'est la protection de soi-meme, retourner le path
72 72
 	if ($mode !== 'force' and preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) {
73
-		$source = substr(_DIR_IMG, strlen(_DIR_RACINE)) . urldecode($match[1]);
73
+		$source = substr(_DIR_IMG, strlen(_DIR_RACINE)).urldecode($match[1]);
74 74
 
75 75
 		return @file_exists($source) ? $source : false;
76 76
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		return false;
91 91
 	}
92 92
 
93
-	$localrac = _DIR_RACINE . $local;
93
+	$localrac = _DIR_RACINE.$local;
94 94
 	$t = ($mode === 'force') ? false : @file_exists($localrac);
95 95
 
96 96
 	// test d'existence du fichier
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 			['file' => $localrac, 'taille_max' => $taille_max, 'if_modified_since' => $t ? filemtime($localrac) : '']
116 116
 		);
117 117
 		if (!$res or (!$res['length'] and $res['status'] != 304)) {
118
-			spip_log("copie_locale : Echec recuperation $source sur $localrac status : " . ($res ? $res['status'] : '-'), 'distant' . _LOG_INFO_IMPORTANTE);
118
+			spip_log("copie_locale : Echec recuperation $source sur $localrac status : ".($res ? $res['status'] : '-'), 'distant'._LOG_INFO_IMPORTANTE);
119 119
 		}
120 120
 		else {
121
-			spip_log("copie_locale : recuperation $source sur $localrac OK | taille " . $res['length'] . ' status ' . $res['status'], 'distant');
121
+			spip_log("copie_locale : recuperation $source sur $localrac OK | taille ".$res['length'].' status '.$res['status'], 'distant');
122 122
 		}
123 123
 		if (!$res or !$res['length']) {
124 124
 			// si $t c'est sans doute juste un not-modified-since
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 
208 208
 	if (!$is_known_host) {
209 209
 		$host = trim($parsed_url['host'], '.');
210
-		if (! $ip = filter_var($host, FILTER_VALIDATE_IP)) {
210
+		if (!$ip = filter_var($host, FILTER_VALIDATE_IP)) {
211 211
 			$ip = gethostbyname($host);
212 212
 			if ($ip === $host) {
213 213
 				// Error condition for gethostbyname()
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			}
229 229
 		}
230 230
 		if ($ip) {
231
-			if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
231
+			if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
232 232
 				return false;
233 233
 			}
234 234
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	$port = $parsed_url['port'];
242
-	if ($port === 80  or $port === 443  or $port === 8080) {
242
+	if ($port === 80 or $port === 443 or $port === 8080) {
243 243
 		return $url;
244 244
 	}
245 245
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				}
310 310
 			}
311 311
 			if ($taille > 500) {
312
-				$boundary = substr(md5(random_int(0, mt_getrandmax()) . 'spip'), 0, 8);
312
+				$boundary = substr(md5(random_int(0, mt_getrandmax()).'spip'), 0, 8);
313 313
 			}
314 314
 		}
315 315
 
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 			}
338 338
 		} else {
339 339
 			// fabrique une chaine HTTP simple pour un POST
340
-			$entete = 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
340
+			$entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n";
341 341
 			$chaine = [];
342 342
 			if (is_array($donnees)) {
343 343
 				foreach ($donnees as $cle => $valeur) {
344 344
 					if (is_array($valeur)) {
345 345
 						foreach ($valeur as $val2) {
346
-							$chaine[] = rawurlencode($cle) . '[]=' . rawurlencode($val2);
346
+							$chaine[] = rawurlencode($cle).'[]='.rawurlencode($val2);
347 347
 						}
348 348
 					} else {
349
-						$chaine[] = rawurlencode($cle) . '=' . rawurlencode($valeur);
349
+						$chaine[] = rawurlencode($cle).'='.rawurlencode($valeur);
350 350
 					}
351 351
 				}
352 352
 				$chaine = implode('&', $chaine);
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
 		$options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE;
452 452
 	}
453 453
 
454
-	spip_log("recuperer_url " . $options['methode']. " sur $url", 'distant' . _LOG_DEBUG);
454
+	spip_log("recuperer_url ".$options['methode']." sur $url", 'distant'._LOG_DEBUG);
455 455
 
456 456
 	// Ajout des en-têtes spécifiques si besoin
457 457
 	$formatted_data = '';
458 458
 	if (!empty($options['headers'])) {
459 459
 		foreach ($options['headers'] as $champ => $valeur) {
460
-			$formatted_data .= $champ . ': ' . $valeur . "\r\n";
460
+			$formatted_data .= $champ.': '.$valeur."\r\n";
461 461
 		}
462 462
 	}
463 463
 
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 		[$head, $postdata] = prepare_donnees_post($options['datas'], $options['boundary']);
466 466
 		$head .= $formatted_data;
467 467
 		if (stripos($head, 'Content-Length:') === false) {
468
-			$head .= 'Content-Length: ' . strlen($postdata) . "\r\n";
468
+			$head .= 'Content-Length: '.strlen($postdata)."\r\n";
469 469
 		}
470
-		$formatted_data = $head . "\r\n" . $postdata;
470
+		$formatted_data = $head."\r\n".$postdata;
471 471
 		if (
472 472
 			strlen($postdata)
473 473
 			and !$methode_demandee
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 	// Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole
482 482
 	$url = preg_replace(',^feed://,i', 'http://', $url);
483 483
 	if (!tester_url_absolue($url)) {
484
-		$url = 'http://' . $url;
484
+		$url = 'http://'.$url;
485 485
 	} elseif (strncmp($url, '//', 2) == 0) {
486
-		$url = 'http:' . $url;
486
+		$url = 'http:'.$url;
487 487
 	}
488 488
 
489 489
 	$url = url_to_ascii($url);
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		$options['if_modified_since']
513 513
 	);
514 514
 	if (!$handle) {
515
-		spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR);
515
+		spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR);
516 516
 
517 517
 		return false;
518 518
 	}
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 					'status' => 200,
543 543
 				];
544 544
 			} else {
545
-				spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR);
545
+				spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR);
546 546
 				return false;
547 547
 			}
548 548
 		} elseif ($res['location'] and $options['follow_location']) {
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 					$options['datas'] = '';
559 559
 				}
560 560
 			}
561
-			spip_log("recuperer_url recommence " . $options['methode']. " sur $url", 'distant' . _LOG_DEBUG);
561
+			spip_log("recuperer_url recommence ".$options['methode']." sur $url", 'distant'._LOG_DEBUG);
562 562
 
563 563
 			return recuperer_url($url, $options);
564 564
 		} elseif ($res['status'] !== 200) {
565
-			spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant');
565
+			spip_log('HTTP status '.$res['status']." pour $url", 'distant');
566 566
 		}
567 567
 		$result['status'] = $res['status'];
568 568
 		if (isset($res['headers'])) {
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
 	// on ne veut que les entetes
580 580
 	if (!$options['taille_max'] or $options['methode'] == 'HEAD' or $result['status'] == '304') {
581
-		spip_log("RESULTAT recuperer_url " . $options['methode']. " sur $url : " . json_encode($result), 'distant' . _LOG_DEBUG);
581
+		spip_log("RESULTAT recuperer_url ".$options['methode']." sur $url : ".json_encode($result), 'distant'._LOG_DEBUG);
582 582
 		return $result;
583 583
 	}
584 584
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
 	$gz = false;
590 590
 	if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) {
591
-		$gz = (_DIR_TMP . md5(uniqid(random_int(0, mt_getrandmax()))) . '.tmp.gz');
591
+		$gz = (_DIR_TMP.md5(uniqid(random_int(0, mt_getrandmax()))).'.tmp.gz');
592 592
 	}
593 593
 
594 594
 	// si on a pas deja recuperer le contenu par une methode detournee
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 
625 625
 	$trace = json_decode(json_encode($result), true);
626 626
 	$trace['page'] = '...';
627
-	spip_log("RESULTAT recuperer_url " . $options['methode']. " sur $url : " . json_encode($trace), 'distant' . _LOG_DEBUG);
627
+	spip_log("RESULTAT recuperer_url ".$options['methode']." sur $url : ".json_encode($trace), 'distant'._LOG_DEBUG);
628 628
 
629 629
 	return $result;
630 630
 }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	$sig['url'] = $url;
679 679
 
680 680
 	$dir = sous_repertoire(_DIR_CACHE, 'curl');
681
-	$cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80);
681
+	$cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80);
682 682
 	$sub = sous_repertoire($dir, substr($cache, 0, 2));
683 683
 	$cache = "$sub$cache";
684 684
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	$fp = false;
733 733
 	if ($fichier) {
734 734
 		include_spip('inc/acces');
735
-		$tmpfile = "$fichier." . creer_uniqid() . '.tmp';
735
+		$tmpfile = "$fichier.".creer_uniqid().'.tmp';
736 736
 		$fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX);
737 737
 		if (!$fp and file_exists($fichier)) {
738 738
 			return filesize($fichier);
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	}
792 792
 	$result['status'] = intval($r[1]);
793 793
 	while ($s = trim(fgets($handle, 16384))) {
794
-		$result['headers'][] = $s . "\n";
794
+		$result['headers'][] = $s."\n";
795 795
 		preg_match(',^([^:]*): *(.*)$,i', $s, $r);
796 796
 		[, $d, $v] = $r;
797 797
 		if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) {
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
 
841 841
 	// on se place tout le temps comme si on etait a la racine
842 842
 	if (_DIR_RACINE) {
843
-		$d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d);
843
+		$d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d);
844 844
 	}
845 845
 
846 846
 	$m = md5($source);
847 847
 
848 848
 	return $d
849
-	. substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12)
849
+	. substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12)
850 850
 	. substr($m, 0, 4)
851 851
 	. ".$extension";
852 852
 }
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 	// Si c'est deja local pas de souci
870 870
 	if (!tester_url_absolue($source)) {
871 871
 		if (_DIR_RACINE) {
872
-			$source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source);
872
+			$source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source);
873 873
 		}
874 874
 
875 875
 		return $source;
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 		$ext
888 888
 		and preg_match(',^\w+$,', $ext) // pas de php?truc=1&...
889 889
 		and $f = nom_fichier_copie_locale($source, $ext)
890
-		and file_exists(_DIR_RACINE . $f)
890
+		and file_exists(_DIR_RACINE.$f)
891 891
 	) {
892 892
 		return $f;
893 893
 	}
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 
896 896
 	// Si c'est deja dans la table des documents,
897 897
 	// ramener le nom de sa copie potentielle
898
-	$ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''");
898
+	$ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''");
899 899
 
900 900
 	if ($ext) {
901 901
 		return nom_fichier_copie_locale($source, $ext);
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
 
907 907
 	$ext = $path_parts ? $path_parts['extension'] : '';
908 908
 
909
-	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) {
909
+	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) {
910 910
 		$f = nom_fichier_copie_locale($source, $ext);
911
-		if (file_exists(_DIR_RACINE . $f)) {
911
+		if (file_exists(_DIR_RACINE.$f)) {
912 912
 			return $f;
913 913
 		}
914 914
 	}
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 	// Ping  pour voir si son extension est connue et autorisee
917 917
 	// avec mise en cache du resultat du ping
918 918
 
919
-	$cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source);
919
+	$cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source);
920 920
 	if (
921 921
 		!@file_exists($cache)
922 922
 		or !$path_parts = @unserialize(spip_file_get_contents($cache))
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
 		ecrire_fichier($cache, serialize($path_parts));
927 927
 	}
928 928
 	$ext = !empty($path_parts['extension']) ? $path_parts['extension'] : '';
929
-	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) {
929
+	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) {
930 930
 		return nom_fichier_copie_locale($source, $ext);
931 931
 	}
932
-	spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR);
932
+	spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR);
933 933
 }
934 934
 
935 935
 
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 		} else {
1014 1014
 			if ($a['body']) {
1015 1015
 				$a['extension'] = $extension;
1016
-				$a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension);
1016
+				$a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension);
1017 1017
 				ecrire_fichier($a['fichier'], $a['body']);
1018 1018
 				$size_image = @spip_getimagesize($a['fichier']);
1019 1019
 				$a['largeur'] = intval($size_image[0]);
@@ -1081,20 +1081,20 @@  discard block
 block discarded – undo
1081 1081
 			!$t
1082 1082
 			and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
1083 1083
 		) {
1084
-			$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1084
+			$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1085 1085
 		}
1086 1086
 		if (
1087 1087
 			!$t
1088 1088
 			and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m)
1089 1089
 			and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext)
1090 1090
 		) {
1091
-			$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1091
+			$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1092 1092
 		}
1093 1093
 	}
1094 1094
 
1095 1095
 	// Autre mime/type (ou text/plain avec fichier d'extension inconnue)
1096 1096
 	if (!$t) {
1097
-		$t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type));
1097
+		$t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type));
1098 1098
 	}
1099 1099
 
1100 1100
 	// Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg)
@@ -1105,11 +1105,11 @@  discard block
 block discarded – undo
1105 1105
 		and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
1106 1106
 	) {
1107 1107
 		# eviter xxx.3 => 3gp (> SPIP 3)
1108
-		$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1108
+		$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1109 1109
 	}
1110 1110
 
1111 1111
 	if ($t) {
1112
-		spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant');
1112
+		spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant');
1113 1113
 		return $t['extension'];
1114 1114
 	} else {
1115 1115
 		# par defaut on retombe sur '.bin' si c'est autorise
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 		}
1213 1213
 	} else {
1214 1214
 		$scheme = $t['scheme'];
1215
-		$noproxy = $scheme . '://';
1215
+		$noproxy = $scheme.'://';
1216 1216
 	}
1217 1217
 	if (isset($t['user'])) {
1218 1218
 		$user = [$t['user'], $t['pass']];
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	}
1227 1227
 
1228 1228
 	if (!empty($t['query'])) {
1229
-		$path .= '?' . $t['query'];
1229
+		$path .= '?'.$t['query'];
1230 1230
 	}
1231 1231
 
1232 1232
 	$f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date);
@@ -1300,20 +1300,20 @@  discard block
 block discarded – undo
1300 1300
 	$proxy_user = '';
1301 1301
 	$http_proxy = need_proxy($host);
1302 1302
 	if ($user) {
1303
-		$user = urlencode($user[0]) . ':' . urlencode($user[1]);
1303
+		$user = urlencode($user[0]).':'.urlencode($user[1]);
1304 1304
 	}
1305 1305
 
1306 1306
 	$connect = '';
1307 1307
 	if ($http_proxy) {
1308
-		if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls','ssl'])) {
1309
-			$path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : '');
1310
-			$connect = 'CONNECT ' . $path_host . " $vers\r\n"
1308
+		if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls', 'ssl'])) {
1309
+			$path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : '');
1310
+			$connect = 'CONNECT '.$path_host." $vers\r\n"
1311 1311
 				. "Host: $path_host\r\n"
1312 1312
 				. "Proxy-Connection: Keep-Alive\r\n";
1313 1313
 		} else {
1314
-			$path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://")
1314
+			$path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://")
1315 1315
 				. (!$user ? '' : "$user@")
1316
-				. "$host" . (($port != 80) ? ":$port" : '') . $path;
1316
+				. "$host".(($port != 80) ? ":$port" : '').$path;
1317 1317
 		}
1318 1318
 		$t2 = @parse_url($http_proxy);
1319 1319
 		$first_host = $t2['host'];
@@ -1321,10 +1321,10 @@  discard block
 block discarded – undo
1321 1321
 			$port = 80;
1322 1322
 		}
1323 1323
 		if ($t2['user']) {
1324
-			$proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']);
1324
+			$proxy_user = base64_encode($t2['user'].':'.$t2['pass']);
1325 1325
 		}
1326 1326
 	} else {
1327
-		$first_host = $noproxy . $host;
1327
+		$first_host = $noproxy.$host;
1328 1328
 	}
1329 1329
 
1330 1330
 	if ($connect) {
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 		);
1347 1347
 		spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", 'connect');
1348 1348
 		if (!$f) {
1349
-			spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR);
1349
+			spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR);
1350 1350
 			return $errno;
1351 1351
 		}
1352 1352
 		stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT);
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
 			or !count($res = explode(' ', $res))
1360 1360
 			or $res[1] !== '200'
1361 1361
 		) {
1362
-			spip_log("Echec CONNECT sur $first_host:$port", 'connect' . _LOG_INFO_IMPORTANTE);
1362
+			spip_log("Echec CONNECT sur $first_host:$port", 'connect'._LOG_INFO_IMPORTANTE);
1363 1363
 			fclose($f);
1364 1364
 
1365 1365
 			return false;
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		} while (!$f and $ntry-- and $errno !== 110 and sleep(1));
1377 1377
 		spip_log("Recuperer $path sur $first_host:$port par $f");
1378 1378
 		if (!$f) {
1379
-			spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR);
1379
+			spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR);
1380 1380
 
1381 1381
 			return $errno;
1382 1382
 		}
@@ -1386,16 +1386,16 @@  discard block
 block discarded – undo
1386 1386
 	$site = $GLOBALS['meta']['adresse_site'] ?? '';
1387 1387
 
1388 1388
 	$host_port = $host;
1389
-	if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) {
1389
+	if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) {
1390 1390
 		$host_port .= ":$port";
1391 1391
 	}
1392 1392
 	$req = "$method $path $vers\r\n"
1393 1393
 		. "Host: $host_port\r\n"
1394
-		. 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n"
1395
-		. ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n"))
1394
+		. 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n"
1395
+		. ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n"))
1396 1396
 		. (!$site ? '' : "Referer: $site/$referer\r\n")
1397
-		. (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n"))
1398
-		. (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n"))
1397
+		. (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n"))
1398
+		. (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n"))
1399 1399
 		. (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n")
1400 1400
 		. (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n");
1401 1401
 
Please login to merge, or discard this patch.