@@ -26,7 +26,7 @@ discard block |
||
| 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', 2097152); |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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() |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | foreach ($records as $record) { |
| 218 | 218 | // il faut que le TTL soit suffisant afin d'etre certain que le copie_locale eventuel qui suit |
| 219 | 219 | // se fasse sur la meme IP |
| 220 | - if ($record['ttl']<10) { |
|
| 220 | + if ($record['ttl'] < 10) { |
|
| 221 | 221 | $ip = false; |
| 222 | 222 | break; |
| 223 | 223 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | if ($taille > 500) { |
| 312 | - $boundary = substr(md5(rand() . 'spip'), 0, 8); |
|
| 312 | + $boundary = substr(md5(rand().'spip'), 0, 8); |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
@@ -337,16 +337,16 @@ discard block |
||
| 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); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $url_idn = implode($host_ascii, $url_idn); |
| 381 | 381 | } |
| 382 | 382 | // et on urlencode les char utf si besoin dans le path |
| 383 | - $url_idn = preg_replace_callback('/[^\x20-\x7f]/', function ($match) { |
|
| 383 | + $url_idn = preg_replace_callback('/[^\x20-\x7f]/', function($match) { |
|
| 384 | 384 | return urlencode($match[0]); |
| 385 | 385 | }, $url_idn); |
| 386 | 386 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $head_add = ''; |
| 459 | 459 | if (!empty($options['headers'])) { |
| 460 | 460 | foreach ($options['headers'] as $champ => $valeur) { |
| 461 | - $head_add .= $champ . ': ' . $valeur . "\r\n"; |
|
| 461 | + $head_add .= $champ.': '.$valeur."\r\n"; |
|
| 462 | 462 | } |
| 463 | 463 | // ne pas le repasser a recuperer_url si on follow un location, car ils seront dans datas |
| 464 | 464 | unset($options['headers']); |
@@ -468,9 +468,9 @@ discard block |
||
| 468 | 468 | list($head, $postdata) = prepare_donnees_post($options['datas'], $options['boundary']); |
| 469 | 469 | $head .= $head_add; |
| 470 | 470 | if (stripos($head, 'Content-Length:') === false) { |
| 471 | - $head .= 'Content-Length: ' . strlen($postdata) . "\r\n"; |
|
| 471 | + $head .= 'Content-Length: '.strlen($postdata)."\r\n"; |
|
| 472 | 472 | } |
| 473 | - $options['datas'] = $head . "\r\n" . $postdata; |
|
| 473 | + $options['datas'] = $head."\r\n".$postdata; |
|
| 474 | 474 | if ( |
| 475 | 475 | strlen($postdata) |
| 476 | 476 | and !$methode_demandee |
@@ -478,15 +478,15 @@ discard block |
||
| 478 | 478 | $options['methode'] = 'POST'; |
| 479 | 479 | } |
| 480 | 480 | } elseif ($head_add) { |
| 481 | - $options['datas'] = $head_add . "\r\n"; |
|
| 481 | + $options['datas'] = $head_add."\r\n"; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | // Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole |
| 485 | 485 | $url = preg_replace(',^feed://,i', 'http://', $url); |
| 486 | 486 | if (!tester_url_absolue($url)) { |
| 487 | - $url = 'http://' . $url; |
|
| 487 | + $url = 'http://'.$url; |
|
| 488 | 488 | } elseif (strncmp($url, '//', 2) == 0) { |
| 489 | - $url = 'http:' . $url; |
|
| 489 | + $url = 'http:'.$url; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | $url = url_to_ascii($url); |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $options['if_modified_since'] |
| 516 | 516 | ); |
| 517 | 517 | if (!$handle) { |
| 518 | - spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR); |
|
| 518 | + spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR); |
|
| 519 | 519 | |
| 520 | 520 | return false; |
| 521 | 521 | } |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | 'status' => 200, |
| 546 | 546 | ]; |
| 547 | 547 | } else { |
| 548 | - spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR); |
|
| 548 | + spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR); |
|
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | } elseif ($res['location'] and $options['follow_location']) { |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | return recuperer_url($url, $options); |
| 559 | 559 | } elseif ($res['status'] !== 200) { |
| 560 | - spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant'); |
|
| 560 | + spip_log('HTTP status '.$res['status']." pour $url", 'distant'); |
|
| 561 | 561 | } |
| 562 | 562 | $result['status'] = $res['status']; |
| 563 | 563 | if (isset($res['headers'])) { |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | |
| 583 | 583 | $gz = false; |
| 584 | 584 | if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) { |
| 585 | - $gz = (_DIR_TMP . md5(uniqid(mt_rand())) . '.tmp.gz'); |
|
| 585 | + $gz = (_DIR_TMP.md5(uniqid(mt_rand())).'.tmp.gz'); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | // si on a pas deja recuperer le contenu par une methode detournee |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | $sig['url'] = $url; |
| 669 | 669 | |
| 670 | 670 | $dir = sous_repertoire(_DIR_CACHE, 'curl'); |
| 671 | - $cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 671 | + $cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 672 | 672 | $sub = sous_repertoire($dir, substr($cache, 0, 2)); |
| 673 | 673 | $cache = "$sub$cache"; |
| 674 | 674 | |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | $fp = false; |
| 722 | 722 | if ($fichier) { |
| 723 | 723 | include_spip('inc/acces'); |
| 724 | - $tmpfile = "$fichier." . creer_uniqid() . '.tmp'; |
|
| 724 | + $tmpfile = "$fichier.".creer_uniqid().'.tmp'; |
|
| 725 | 725 | $fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX); |
| 726 | 726 | if (!$fp and file_exists($fichier)) { |
| 727 | 727 | return filesize($fichier); |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | $result['status'] = intval($r[1]); |
| 782 | 782 | while ($s = trim(fgets($handle, 16384))) { |
| 783 | - $result['headers'][] = $s . "\n"; |
|
| 783 | + $result['headers'][] = $s."\n"; |
|
| 784 | 784 | preg_match(',^([^:]*): *(.*)$,i', $s, $r); |
| 785 | 785 | list(, $d, $v) = $r; |
| 786 | 786 | if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) { |
@@ -829,13 +829,13 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | // on se place tout le temps comme si on etait a la racine |
| 831 | 831 | if (_DIR_RACINE) { |
| 832 | - $d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d); |
|
| 832 | + $d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | $m = md5($source); |
| 836 | 836 | |
| 837 | 837 | return $d |
| 838 | - . substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12) |
|
| 838 | + . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12) |
|
| 839 | 839 | . substr($m, 0, 4) |
| 840 | 840 | . ".$extension"; |
| 841 | 841 | } |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | // Si c'est deja local pas de souci |
| 859 | 859 | if (!tester_url_absolue($source)) { |
| 860 | 860 | if (_DIR_RACINE) { |
| 861 | - $source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source); |
|
| 861 | + $source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | return $source; |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | $ext |
| 877 | 877 | and preg_match(',^\w+$,', $ext) // pas de php?truc=1&... |
| 878 | 878 | and $f = nom_fichier_copie_locale($source, $ext) |
| 879 | - and file_exists(_DIR_RACINE . $f) |
|
| 879 | + and file_exists(_DIR_RACINE.$f) |
|
| 880 | 880 | ) { |
| 881 | 881 | return $f; |
| 882 | 882 | } |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | // Si c'est deja dans la table des documents, |
| 886 | 886 | // ramener le nom de sa copie potentielle |
| 887 | - $ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''"); |
|
| 887 | + $ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''"); |
|
| 888 | 888 | |
| 889 | 889 | if ($ext) { |
| 890 | 890 | return nom_fichier_copie_locale($source, $ext); |
@@ -895,9 +895,9 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | $ext = $path_parts ? $path_parts['extension'] : ''; |
| 897 | 897 | |
| 898 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 898 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 899 | 899 | $f = nom_fichier_copie_locale($source, $ext); |
| 900 | - if (file_exists(_DIR_RACINE . $f)) { |
|
| 900 | + if (file_exists(_DIR_RACINE.$f)) { |
|
| 901 | 901 | return $f; |
| 902 | 902 | } |
| 903 | 903 | } |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | // Ping pour voir si son extension est connue et autorisee |
| 906 | 906 | // avec mise en cache du resultat du ping |
| 907 | 907 | |
| 908 | - $cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source); |
|
| 908 | + $cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source); |
|
| 909 | 909 | if ( |
| 910 | 910 | !@file_exists($cache) |
| 911 | 911 | or !$path_parts = @unserialize(spip_file_get_contents($cache)) |
@@ -915,10 +915,10 @@ discard block |
||
| 915 | 915 | ecrire_fichier($cache, serialize($path_parts)); |
| 916 | 916 | } |
| 917 | 917 | $ext = !empty($path_parts['extension']) ? $path_parts['extension'] : ''; |
| 918 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 918 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 919 | 919 | return nom_fichier_copie_locale($source, $ext); |
| 920 | 920 | } |
| 921 | - spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR); |
|
| 921 | + spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | } else { |
| 1003 | 1003 | if ($a['body']) { |
| 1004 | 1004 | $a['extension'] = $extension; |
| 1005 | - $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension); |
|
| 1005 | + $a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension); |
|
| 1006 | 1006 | ecrire_fichier($a['fichier'], $a['body']); |
| 1007 | 1007 | $size_image = @spip_getimagesize($a['fichier']); |
| 1008 | 1008 | $a['largeur'] = intval($size_image[0]); |
@@ -1070,20 +1070,20 @@ discard block |
||
| 1070 | 1070 | !$t |
| 1071 | 1071 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1072 | 1072 | ) { |
| 1073 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1073 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | if ( |
| 1076 | 1076 | !$t |
| 1077 | 1077 | and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m) |
| 1078 | 1078 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext) |
| 1079 | 1079 | ) { |
| 1080 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1080 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | // Autre mime/type (ou text/plain avec fichier d'extension inconnue) |
| 1085 | 1085 | if (!$t) { |
| 1086 | - $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type)); |
|
| 1086 | + $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type)); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) |
@@ -1094,11 +1094,11 @@ discard block |
||
| 1094 | 1094 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1095 | 1095 | ) { |
| 1096 | 1096 | # eviter xxx.3 => 3gp (> SPIP 3) |
| 1097 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1097 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | if ($t) { |
| 1101 | - spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant'); |
|
| 1101 | + spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant'); |
|
| 1102 | 1102 | return $t['extension']; |
| 1103 | 1103 | } else { |
| 1104 | 1104 | # par defaut on retombe sur '.bin' si c'est autorise |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | } else { |
| 1203 | 1203 | $scheme = $t['scheme']; |
| 1204 | - $noproxy = $scheme . '://'; |
|
| 1204 | + $noproxy = $scheme.'://'; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | if (isset($t['user'])) { |
| 1207 | 1207 | $user = [$t['user'], $t['pass']]; |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | if (!empty($t['query'])) { |
| 1218 | - $path .= '?' . $t['query']; |
|
| 1218 | + $path .= '?'.$t['query']; |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date); |
@@ -1289,20 +1289,20 @@ discard block |
||
| 1289 | 1289 | $proxy_user = ''; |
| 1290 | 1290 | $http_proxy = need_proxy($host); |
| 1291 | 1291 | if ($user) { |
| 1292 | - $user = urlencode($user[0]) . ':' . urlencode($user[1]); |
|
| 1292 | + $user = urlencode($user[0]).':'.urlencode($user[1]); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | $connect = ''; |
| 1296 | 1296 | if ($http_proxy) { |
| 1297 | - if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls','ssl'])) { |
|
| 1298 | - $path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : ''); |
|
| 1299 | - $connect = 'CONNECT ' . $path_host . " $vers\r\n" |
|
| 1297 | + if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls', 'ssl'])) { |
|
| 1298 | + $path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : ''); |
|
| 1299 | + $connect = 'CONNECT '.$path_host." $vers\r\n" |
|
| 1300 | 1300 | . "Host: $path_host\r\n" |
| 1301 | 1301 | . "Proxy-Connection: Keep-Alive\r\n"; |
| 1302 | 1302 | } else { |
| 1303 | - $path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://") |
|
| 1303 | + $path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://") |
|
| 1304 | 1304 | . (!$user ? '' : "$user@") |
| 1305 | - . "$host" . (($port != 80) ? ":$port" : '') . $path; |
|
| 1305 | + . "$host".(($port != 80) ? ":$port" : '').$path; |
|
| 1306 | 1306 | } |
| 1307 | 1307 | $t2 = @parse_url($http_proxy); |
| 1308 | 1308 | $first_host = $t2['host']; |
@@ -1310,10 +1310,10 @@ discard block |
||
| 1310 | 1310 | $port = 80; |
| 1311 | 1311 | } |
| 1312 | 1312 | if ($t2['user']) { |
| 1313 | - $proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']); |
|
| 1313 | + $proxy_user = base64_encode($t2['user'].':'.$t2['pass']); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | } else { |
| 1316 | - $first_host = $noproxy . $host; |
|
| 1316 | + $first_host = $noproxy.$host; |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | if ($connect) { |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | ); |
| 1336 | 1336 | spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", 'connect'); |
| 1337 | 1337 | if (!$f) { |
| 1338 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1338 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1339 | 1339 | return $errno; |
| 1340 | 1340 | } |
| 1341 | 1341 | stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); |
@@ -1348,7 +1348,7 @@ discard block |
||
| 1348 | 1348 | or !count($res = explode(' ', $res)) |
| 1349 | 1349 | or $res[1] !== '200' |
| 1350 | 1350 | ) { |
| 1351 | - spip_log("Echec CONNECT sur $first_host:$port", 'connect' . _LOG_INFO_IMPORTANTE); |
|
| 1351 | + spip_log("Echec CONNECT sur $first_host:$port", 'connect'._LOG_INFO_IMPORTANTE); |
|
| 1352 | 1352 | fclose($f); |
| 1353 | 1353 | |
| 1354 | 1354 | return false; |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | } while (!$f and $ntry-- and $errno !== 110 and sleep(1)); |
| 1366 | 1366 | spip_log("Recuperer $path sur $first_host:$port par $f"); |
| 1367 | 1367 | if (!$f) { |
| 1368 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1368 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1369 | 1369 | |
| 1370 | 1370 | return $errno; |
| 1371 | 1371 | } |
@@ -1375,16 +1375,16 @@ discard block |
||
| 1375 | 1375 | $site = isset($GLOBALS['meta']['adresse_site']) ? $GLOBALS['meta']['adresse_site'] : ''; |
| 1376 | 1376 | |
| 1377 | 1377 | $host_port = $host; |
| 1378 | - if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) { |
|
| 1378 | + if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) { |
|
| 1379 | 1379 | $host_port .= ":$port"; |
| 1380 | 1380 | } |
| 1381 | 1381 | $req = "$method $path $vers\r\n" |
| 1382 | 1382 | . "Host: $host_port\r\n" |
| 1383 | - . 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n" |
|
| 1384 | - . ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n")) |
|
| 1383 | + . 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n" |
|
| 1384 | + . ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n")) |
|
| 1385 | 1385 | . (!$site ? '' : "Referer: $site/$referer\r\n") |
| 1386 | - . (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n")) |
|
| 1387 | - . (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n")) |
|
| 1386 | + . (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n")) |
|
| 1387 | + . (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n")) |
|
| 1388 | 1388 | . (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n") |
| 1389 | 1389 | . (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n"); |
| 1390 | 1390 | |