@@ -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,13 +115,13 @@ discard block |
||
| 115 | 115 | array('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['status'], 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 118 | + spip_log("copie_locale : Echec recuperation $source sur $localrac status : ".$res['status'], 'distant'._LOG_INFO_IMPORTANTE); |
|
| 119 | 119 | } |
| 120 | 120 | if (!$res['length']) { |
| 121 | 121 | // si $t c'est sans doute juste un not-modified-since |
| 122 | 122 | return $t ? $local : false; |
| 123 | 123 | } |
| 124 | - spip_log("copie_locale : recuperation $source sur $localrac taille " . $res['length'] . ' OK', 'distant'); |
|
| 124 | + spip_log("copie_locale : recuperation $source sur $localrac taille ".$res['length'].' OK', 'distant'); |
|
| 125 | 125 | |
| 126 | 126 | // pour une eventuelle indexation |
| 127 | 127 | pipeline( |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * url ou false en cas d'echec |
| 154 | 154 | */ |
| 155 | 155 | function valider_url_distante($url, $known_hosts = array()) { |
| 156 | - if (!function_exists('protocole_verifier')){ |
|
| 156 | + if (!function_exists('protocole_verifier')) { |
|
| 157 | 157 | include_spip('inc/filtres_mini'); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $parsed_url = parse_url($url); |
| 165 | - if (!$parsed_url or empty($parsed_url['host']) ) { |
|
| 165 | + if (!$parsed_url or empty($parsed_url['host'])) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | if ($ip) { |
| 206 | - $parts = array_map('intval', explode( '.', $ip )); |
|
| 206 | + $parts = array_map('intval', explode('.', $ip)); |
|
| 207 | 207 | if (127 === $parts[0] or 10 === $parts[0] or 0 === $parts[0] |
| 208 | - or ( 172 === $parts[0] and 16 <= $parts[1] and 31 >= $parts[1] ) |
|
| 209 | - or ( 192 === $parts[0] && 168 === $parts[1] ) |
|
| 208 | + or (172 === $parts[0] and 16 <= $parts[1] and 31 >= $parts[1]) |
|
| 209 | + or (192 === $parts[0] && 168 === $parts[1]) |
|
| 210 | 210 | ) { |
| 211 | 211 | return false; |
| 212 | 212 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $port = $parsed_url['port']; |
| 221 | - if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 221 | + if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 222 | 222 | return $url; |
| 223 | 223 | } |
| 224 | 224 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | if ($taille > 500) { |
| 289 | - $boundary = substr(md5(rand() . 'spip'), 0, 8); |
|
| 289 | + $boundary = substr(md5(rand().'spip'), 0, 8); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
@@ -314,16 +314,16 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | } else { |
| 316 | 316 | // fabrique une chaine HTTP simple pour un POST |
| 317 | - $entete = 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; |
|
| 317 | + $entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n"; |
|
| 318 | 318 | $chaine = array(); |
| 319 | 319 | if (is_array($donnees)) { |
| 320 | 320 | foreach ($donnees as $cle => $valeur) { |
| 321 | 321 | if (is_array($valeur)) { |
| 322 | 322 | foreach ($valeur as $val2) { |
| 323 | - $chaine[] = rawurlencode($cle) . '[]=' . rawurlencode($val2); |
|
| 323 | + $chaine[] = rawurlencode($cle).'[]='.rawurlencode($val2); |
|
| 324 | 324 | } |
| 325 | 325 | } else { |
| 326 | - $chaine[] = rawurlencode($cle) . '=' . rawurlencode($valeur); |
|
| 326 | + $chaine[] = rawurlencode($cle).'='.rawurlencode($valeur); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | $chaine = implode('&', $chaine); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $head_add = ''; |
| 434 | 434 | if (!empty($options['headers'])) { |
| 435 | 435 | foreach ($options['headers'] as $champ => $valeur) { |
| 436 | - $head_add .= $champ . ': ' . $valeur . "\r\n"; |
|
| 436 | + $head_add .= $champ.': '.$valeur."\r\n"; |
|
| 437 | 437 | } |
| 438 | 438 | // ne pas le repasser a recuperer_url si on follow un location, car ils seront dans datas |
| 439 | 439 | unset($options['entetes']); |
@@ -443,9 +443,9 @@ discard block |
||
| 443 | 443 | list($head, $postdata) = prepare_donnees_post($options['datas'], $options['boundary']); |
| 444 | 444 | $head .= $head_add; |
| 445 | 445 | if (stripos($head, 'Content-Length:') === false) { |
| 446 | - $head .= 'Content-Length: ' . strlen($postdata) . "\r\n"; |
|
| 446 | + $head .= 'Content-Length: '.strlen($postdata)."\r\n"; |
|
| 447 | 447 | } |
| 448 | - $options['datas'] = $head . "\r\n" . $postdata; |
|
| 448 | + $options['datas'] = $head."\r\n".$postdata; |
|
| 449 | 449 | if ( |
| 450 | 450 | strlen($postdata) |
| 451 | 451 | and !$methode_demandee |
@@ -453,15 +453,15 @@ discard block |
||
| 453 | 453 | $options['methode'] = 'POST'; |
| 454 | 454 | } |
| 455 | 455 | } elseif ($head_add) { |
| 456 | - $options['datas'] = $head_add . "\r\n"; |
|
| 456 | + $options['datas'] = $head_add."\r\n"; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | // Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole |
| 460 | 460 | $url = preg_replace(',^feed://,i', 'http://', $url); |
| 461 | 461 | if (!tester_url_absolue($url)) { |
| 462 | - $url = 'http://' . $url; |
|
| 462 | + $url = 'http://'.$url; |
|
| 463 | 463 | } elseif (strncmp($url, '//', 2) == 0) { |
| 464 | - $url = 'http:' . $url; |
|
| 464 | + $url = 'http:'.$url; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $url = url_to_ascii($url); |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $options['if_modified_since'] |
| 491 | 491 | ); |
| 492 | 492 | if (!$handle) { |
| 493 | - spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR); |
|
| 493 | + spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR); |
|
| 494 | 494 | |
| 495 | 495 | return false; |
| 496 | 496 | } |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | 'status' => 200, |
| 520 | 520 | ); |
| 521 | 521 | } else { |
| 522 | - spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR); |
|
| 522 | + spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR); |
|
| 523 | 523 | return false; |
| 524 | 524 | } |
| 525 | 525 | } elseif ($res['location'] and $options['follow_location']) { |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | return recuperer_url($url, $options); |
| 533 | 533 | } elseif ($res['status'] !== 200) { |
| 534 | - spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant'); |
|
| 534 | + spip_log('HTTP status '.$res['status']." pour $url", 'distant'); |
|
| 535 | 535 | } |
| 536 | 536 | $result['status'] = $res['status']; |
| 537 | 537 | if (isset($res['headers'])) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | |
| 557 | 557 | $gz = false; |
| 558 | 558 | if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) { |
| 559 | - $gz = (_DIR_TMP . md5(uniqid(mt_rand())) . '.tmp.gz'); |
|
| 559 | + $gz = (_DIR_TMP.md5(uniqid(mt_rand())).'.tmp.gz'); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // si on a pas deja recuperer le contenu par une methode detournee |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $sig['url'] = $url; |
| 643 | 643 | |
| 644 | 644 | $dir = sous_repertoire(_DIR_CACHE, 'curl'); |
| 645 | - $cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 645 | + $cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 646 | 646 | $sub = sous_repertoire($dir, substr($cache, 0, 2)); |
| 647 | 647 | $cache = "$sub$cache"; |
| 648 | 648 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $fp = false; |
| 695 | 695 | if ($fichier) { |
| 696 | 696 | include_spip('inc/acces'); |
| 697 | - $tmpfile = "$fichier." . creer_uniqid() . '.tmp'; |
|
| 697 | + $tmpfile = "$fichier.".creer_uniqid().'.tmp'; |
|
| 698 | 698 | $fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX); |
| 699 | 699 | if (!$fp and file_exists($fichier)) { |
| 700 | 700 | return filesize($fichier); |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | } |
| 754 | 754 | $result['status'] = intval($r[1]); |
| 755 | 755 | while ($s = trim(fgets($handle, 16384))) { |
| 756 | - $result['headers'][] = $s . "\n"; |
|
| 756 | + $result['headers'][] = $s."\n"; |
|
| 757 | 757 | preg_match(',^([^:]*): *(.*)$,i', $s, $r); |
| 758 | 758 | list(, $d, $v) = $r; |
| 759 | 759 | if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) { |
@@ -801,13 +801,13 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | // on se place tout le temps comme si on etait a la racine |
| 803 | 803 | if (_DIR_RACINE) { |
| 804 | - $d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d); |
|
| 804 | + $d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | $m = md5($source); |
| 808 | 808 | |
| 809 | 809 | return $d |
| 810 | - . substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12) |
|
| 810 | + . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12) |
|
| 811 | 811 | . substr($m, 0, 4) |
| 812 | 812 | . ".$extension"; |
| 813 | 813 | } |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | // Si c'est deja local pas de souci |
| 831 | 831 | if (!tester_url_absolue($source)) { |
| 832 | 832 | if (_DIR_RACINE) { |
| 833 | - $source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source); |
|
| 833 | + $source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | return $source; |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | if ($ext |
| 848 | 848 | and preg_match(',^\w+$,', $ext) // pas de php?truc=1&... |
| 849 | 849 | and $f = nom_fichier_copie_locale($source, $ext) |
| 850 | - and file_exists(_DIR_RACINE . $f) |
|
| 850 | + and file_exists(_DIR_RACINE.$f) |
|
| 851 | 851 | ) { |
| 852 | 852 | return $f; |
| 853 | 853 | } |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | // Si c'est deja dans la table des documents, |
| 857 | 857 | // ramener le nom de sa copie potentielle |
| 858 | - $ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''"); |
|
| 858 | + $ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''"); |
|
| 859 | 859 | |
| 860 | 860 | if ($ext) { |
| 861 | 861 | return nom_fichier_copie_locale($source, $ext); |
@@ -866,9 +866,9 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | $ext = $path_parts ? $path_parts['extension'] : ''; |
| 868 | 868 | |
| 869 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 869 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 870 | 870 | $f = nom_fichier_copie_locale($source, $ext); |
| 871 | - if (file_exists(_DIR_RACINE . $f)) { |
|
| 871 | + if (file_exists(_DIR_RACINE.$f)) { |
|
| 872 | 872 | return $f; |
| 873 | 873 | } |
| 874 | 874 | } |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | // Ping pour voir si son extension est connue et autorisee |
| 877 | 877 | // avec mise en cache du resultat du ping |
| 878 | 878 | |
| 879 | - $cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source); |
|
| 879 | + $cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source); |
|
| 880 | 880 | if (!@file_exists($cache) |
| 881 | 881 | or !$path_parts = @unserialize(spip_file_get_contents($cache)) |
| 882 | 882 | or _request('var_mode') == 'recalcul' |
@@ -885,10 +885,10 @@ discard block |
||
| 885 | 885 | ecrire_fichier($cache, serialize($path_parts)); |
| 886 | 886 | } |
| 887 | 887 | $ext = !empty($path_parts['extension']) ? $path_parts['extension'] : ''; |
| 888 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 888 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 889 | 889 | return nom_fichier_copie_locale($source, $ext); |
| 890 | 890 | } |
| 891 | - spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR); |
|
| 891 | + spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | |
@@ -954,19 +954,19 @@ discard block |
||
| 954 | 954 | if (!$t |
| 955 | 955 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 956 | 956 | ) { |
| 957 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($rext[1], '', 'text')); |
|
| 957 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote($rext[1], '', 'text')); |
|
| 958 | 958 | } |
| 959 | 959 | if (!$t |
| 960 | 960 | and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m) |
| 961 | 961 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext) |
| 962 | 962 | ) { |
| 963 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($rext[1], '', 'text')); |
|
| 963 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote($rext[1], '', 'text')); |
|
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | // Autre mime/type (ou text/plain avec fichier d'extension inconnue) |
| 968 | 968 | if (!$t) { |
| 969 | - $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type)); |
|
| 969 | + $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type)); |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) |
@@ -976,11 +976,11 @@ discard block |
||
| 976 | 976 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 977 | 977 | ) { |
| 978 | 978 | # eviter xxx.3 => 3gp (> SPIP 3) |
| 979 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($rext[1], '', 'text')); |
|
| 979 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote($rext[1], '', 'text')); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | if ($t) { |
| 983 | - spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant'); |
|
| 983 | + spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant'); |
|
| 984 | 984 | $a['extension'] = $t['extension']; |
| 985 | 985 | } else { |
| 986 | 986 | # par defaut on retombe sur '.bin' si c'est autorise |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | } else { |
| 1023 | 1023 | if ($a['body']) { |
| 1024 | 1024 | $a['extension'] = $extension; |
| 1025 | - $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension); |
|
| 1025 | + $a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension); |
|
| 1026 | 1026 | ecrire_fichier($a['fichier'], $a['body']); |
| 1027 | 1027 | $size_image = @spip_getimagesize($a['fichier']); |
| 1028 | 1028 | $a['largeur'] = intval($size_image[0]); |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | } |
| 1149 | 1149 | } else { |
| 1150 | 1150 | $scheme = $t['scheme']; |
| 1151 | - $noproxy = $scheme . '://'; |
|
| 1151 | + $noproxy = $scheme.'://'; |
|
| 1152 | 1152 | } |
| 1153 | 1153 | if (isset($t['user'])) { |
| 1154 | 1154 | $user = array($t['user'], $t['pass']); |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | if (!empty($t['query'])) { |
| 1165 | - $path .= '?' . $t['query']; |
|
| 1165 | + $path .= '?'.$t['query']; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date); |
@@ -1235,20 +1235,20 @@ discard block |
||
| 1235 | 1235 | $proxy_user = ''; |
| 1236 | 1236 | $http_proxy = need_proxy($host); |
| 1237 | 1237 | if ($user) { |
| 1238 | - $user = urlencode($user[0]) . ':' . urlencode($user[1]); |
|
| 1238 | + $user = urlencode($user[0]).':'.urlencode($user[1]); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | $connect = ''; |
| 1242 | 1242 | if ($http_proxy) { |
| 1243 | - if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme , array('tls','ssl'))) { |
|
| 1244 | - $path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : ''); |
|
| 1245 | - $connect = 'CONNECT ' . $path_host . " $vers\r\n" |
|
| 1243 | + if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, array('tls', 'ssl'))) { |
|
| 1244 | + $path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : ''); |
|
| 1245 | + $connect = 'CONNECT '.$path_host." $vers\r\n" |
|
| 1246 | 1246 | . "Host: $path_host\r\n" |
| 1247 | 1247 | . "Proxy-Connection: Keep-Alive\r\n"; |
| 1248 | 1248 | } else { |
| 1249 | - $path = (in_array($scheme , array('tls','ssl')) ? 'https://' : "$scheme://") |
|
| 1249 | + $path = (in_array($scheme, array('tls', 'ssl')) ? 'https://' : "$scheme://") |
|
| 1250 | 1250 | . (!$user ? '' : "$user@") |
| 1251 | - . "$host" . (($port != 80) ? ":$port" : '') . $path; |
|
| 1251 | + . "$host".(($port != 80) ? ":$port" : '').$path; |
|
| 1252 | 1252 | } |
| 1253 | 1253 | $t2 = @parse_url($http_proxy); |
| 1254 | 1254 | $first_host = $t2['host']; |
@@ -1256,10 +1256,10 @@ discard block |
||
| 1256 | 1256 | $port = 80; |
| 1257 | 1257 | } |
| 1258 | 1258 | if ($t2['user']) { |
| 1259 | - $proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']); |
|
| 1259 | + $proxy_user = base64_encode($t2['user'].':'.$t2['pass']); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | } else { |
| 1262 | - $first_host = $noproxy . $host; |
|
| 1262 | + $first_host = $noproxy.$host; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | if ($connect) { |
@@ -1281,7 +1281,7 @@ discard block |
||
| 1281 | 1281 | ); |
| 1282 | 1282 | spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", 'connect'); |
| 1283 | 1283 | if (!$f) { |
| 1284 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1284 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1285 | 1285 | return $errno; |
| 1286 | 1286 | } |
| 1287 | 1287 | stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | or !count($res = explode(' ', $res)) |
| 1294 | 1294 | or $res[1] !== '200' |
| 1295 | 1295 | ) { |
| 1296 | - spip_log("Echec CONNECT sur $first_host:$port", 'connect' . _LOG_INFO_IMPORTANTE); |
|
| 1296 | + spip_log("Echec CONNECT sur $first_host:$port", 'connect'._LOG_INFO_IMPORTANTE); |
|
| 1297 | 1297 | fclose($f); |
| 1298 | 1298 | |
| 1299 | 1299 | return false; |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | } while (!$f and $ntry-- and $errno !== 110 and sleep(1)); |
| 1311 | 1311 | spip_log("Recuperer $path sur $first_host:$port par $f"); |
| 1312 | 1312 | if (!$f) { |
| 1313 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1313 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1314 | 1314 | |
| 1315 | 1315 | return $errno; |
| 1316 | 1316 | } |
@@ -1320,16 +1320,16 @@ discard block |
||
| 1320 | 1320 | $site = isset($GLOBALS['meta']['adresse_site']) ? $GLOBALS['meta']['adresse_site'] : ''; |
| 1321 | 1321 | |
| 1322 | 1322 | $host_port = $host; |
| 1323 | - if ($port != (in_array($scheme , array('tls','ssl')) ? 443 : 80)) { |
|
| 1323 | + if ($port != (in_array($scheme, array('tls', 'ssl')) ? 443 : 80)) { |
|
| 1324 | 1324 | $host_port .= ":$port"; |
| 1325 | 1325 | } |
| 1326 | 1326 | $req = "$method $path $vers\r\n" |
| 1327 | 1327 | . "Host: $host_port\r\n" |
| 1328 | - . 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n" |
|
| 1329 | - . ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n")) |
|
| 1328 | + . 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n" |
|
| 1329 | + . ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n")) |
|
| 1330 | 1330 | . (!$site ? '' : "Referer: $site/$referer\r\n") |
| 1331 | - . (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n")) |
|
| 1332 | - . (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n")) |
|
| 1331 | + . (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n")) |
|
| 1332 | + . (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n")) |
|
| 1333 | 1333 | . (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n") |
| 1334 | 1334 | . (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n"); |
| 1335 | 1335 | |