@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | define('_INC_DISTANT_CONTENT_ENCODING', 'gzip'); |
| 28 | 28 | } |
| 29 | 29 | if (!defined('_INC_DISTANT_USER_AGENT')) { |
| 30 | - define('_INC_DISTANT_USER_AGENT', 'SPIP-' . $GLOBALS['spip_version_affichee'] . ' (' . $GLOBALS['home_server'] . ')'); |
|
| 30 | + define('_INC_DISTANT_USER_AGENT', 'SPIP-'.$GLOBALS['spip_version_affichee'].' ('.$GLOBALS['home_server'].')'); |
|
| 31 | 31 | } |
| 32 | 32 | if (!defined('_INC_DISTANT_MAX_SIZE')) { |
| 33 | 33 | define('_INC_DISTANT_MAX_SIZE', 2_097_152); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | define('_INC_DISTANT_CONNECT_TIMEOUT', 10); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -define('_REGEXP_COPIE_LOCALE', ',' . |
|
| 39 | +define('_REGEXP_COPIE_LOCALE', ','. |
|
| 40 | 40 | preg_replace( |
| 41 | 41 | '@^https?:@', |
| 42 | 42 | 'https?:', |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // si c'est la protection de soi-meme, retourner le path |
| 75 | 75 | if ($mode !== 'force' and preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) { |
| 76 | - $source = substr(_DIR_IMG, strlen(_DIR_RACINE)) . urldecode($match[1]); |
|
| 76 | + $source = substr(_DIR_IMG, strlen(_DIR_RACINE)).urldecode($match[1]); |
|
| 77 | 77 | |
| 78 | 78 | return @file_exists($source) ? $source : false; |
| 79 | 79 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $localrac = _DIR_RACINE . $local; |
|
| 96 | + $localrac = _DIR_RACINE.$local; |
|
| 97 | 97 | $t = ($mode === 'force') ? false : @file_exists($localrac); |
| 98 | 98 | |
| 99 | 99 | // test d'existence du fichier |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | if (!$taille_max) { |
| 114 | 114 | $taille_max = _COPIE_LOCALE_MAX_SIZE; |
| 115 | 115 | } |
| 116 | - $localrac_tmp = $localrac . '.tmp'; |
|
| 116 | + $localrac_tmp = $localrac.'.tmp'; |
|
| 117 | 117 | $res = recuperer_url( |
| 118 | 118 | $source, |
| 119 | 119 | ['file' => $localrac_tmp, 'taille_max' => $taille_max, 'if_modified_since' => $t ? filemtime($localrac) : ''] |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | if (!$res or (!$res['length'] and $res['status'] != 304)) { |
| 123 | - spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : " . ($res ? $res['status'] : '-'), 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 123 | + spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : ".($res ? $res['status'] : '-'), 'distant'._LOG_INFO_IMPORTANTE); |
|
| 124 | 124 | @unlink($localrac_tmp); |
| 125 | 125 | } |
| 126 | 126 | else { |
| 127 | - spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille " . $res['length'] . ' status ' . $res['status'], 'distant'); |
|
| 127 | + spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille ".$res['length'].' status '.$res['status'], 'distant'); |
|
| 128 | 128 | } |
| 129 | 129 | if (!$res or !$res['length']) { |
| 130 | 130 | // si $t c'est sans doute juste un not-modified-since |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | and is_callable($callback_valider_url) |
| 138 | 138 | and !$callback_valider_url($res['url']) |
| 139 | 139 | ) { |
| 140 | - spip_log('copie_locale : url finale ' . $res['url'] . " non valide, on refuse le fichier $localrac_tmp", 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 140 | + spip_log('copie_locale : url finale '.$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant'._LOG_INFO_IMPORTANTE); |
|
| 141 | 141 | @unlink($localrac_tmp); |
| 142 | 142 | return $t ? $local : false; |
| 143 | 143 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | if (!$is_known_host) { |
| 230 | 230 | $host = trim($parsed_url['host'], '.'); |
| 231 | - if (! $ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 231 | + if (!$ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 232 | 232 | $ip = gethostbyname($host); |
| 233 | 233 | if ($ip === $host) { |
| 234 | 234 | // Error condition for gethostbyname() |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | if ($ip) { |
| 252 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 252 | + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $port = $parsed_url['port']; |
| 263 | - if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 263 | + if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 264 | 264 | return $url; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | if ($taille > 500) { |
| 333 | - $boundary = substr(md5(random_int(0, mt_getrandmax()) . 'spip'), 0, 8); |
|
| 333 | + $boundary = substr(md5(random_int(0, mt_getrandmax()).'spip'), 0, 8); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -358,16 +358,16 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | } else { |
| 360 | 360 | // fabrique une chaine HTTP simple pour un POST |
| 361 | - $entete = 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; |
|
| 361 | + $entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n"; |
|
| 362 | 362 | $chaine = []; |
| 363 | 363 | if (is_array($donnees)) { |
| 364 | 364 | foreach ($donnees as $cle => $valeur) { |
| 365 | 365 | if (is_array($valeur)) { |
| 366 | 366 | foreach ($valeur as $val2) { |
| 367 | - $chaine[] = rawurlencode($cle) . '[]=' . rawurlencode($val2); |
|
| 367 | + $chaine[] = rawurlencode($cle).'[]='.rawurlencode($val2); |
|
| 368 | 368 | } |
| 369 | 369 | } else { |
| 370 | - $chaine[] = rawurlencode($cle) . '=' . rawurlencode($valeur); |
|
| 370 | + $chaine[] = rawurlencode($cle).'='.rawurlencode($valeur); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | $chaine = implode('&', $chaine); |
@@ -468,13 +468,13 @@ discard block |
||
| 468 | 468 | $options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - spip_log('recuperer_url ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 471 | + spip_log('recuperer_url '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 472 | 472 | |
| 473 | 473 | // Ajout des en-têtes spécifiques si besoin |
| 474 | 474 | $formatted_data = ''; |
| 475 | 475 | if (!empty($options['headers'])) { |
| 476 | 476 | foreach ($options['headers'] as $champ => $valeur) { |
| 477 | - $formatted_data .= $champ . ': ' . $valeur . "\r\n"; |
|
| 477 | + $formatted_data .= $champ.': '.$valeur."\r\n"; |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
@@ -482,9 +482,9 @@ discard block |
||
| 482 | 482 | [$head, $postdata] = prepare_donnees_post($options['datas'], $options['boundary']); |
| 483 | 483 | $head .= $formatted_data; |
| 484 | 484 | if (stripos($head, 'Content-Length:') === false) { |
| 485 | - $head .= 'Content-Length: ' . strlen($postdata) . "\r\n"; |
|
| 485 | + $head .= 'Content-Length: '.strlen($postdata)."\r\n"; |
|
| 486 | 486 | } |
| 487 | - $formatted_data = $head . "\r\n" . $postdata; |
|
| 487 | + $formatted_data = $head."\r\n".$postdata; |
|
| 488 | 488 | if ( |
| 489 | 489 | strlen($postdata) |
| 490 | 490 | and !$methode_demandee |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | // Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole |
| 499 | 499 | $url = preg_replace(',^feed://,i', 'http://', $url); |
| 500 | 500 | if (!tester_url_absolue($url)) { |
| 501 | - $url = 'http://' . $url; |
|
| 501 | + $url = 'http://'.$url; |
|
| 502 | 502 | } elseif (strncmp($url, '//', 2) == 0) { |
| 503 | - $url = 'http:' . $url; |
|
| 503 | + $url = 'http:'.$url; |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $url = url_to_ascii($url); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $options['if_modified_since'] |
| 530 | 530 | ); |
| 531 | 531 | if (!$handle) { |
| 532 | - spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR); |
|
| 532 | + spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR); |
|
| 533 | 533 | |
| 534 | 534 | return false; |
| 535 | 535 | } |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | 'status' => 200, |
| 560 | 560 | ]; |
| 561 | 561 | } else { |
| 562 | - spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR); |
|
| 562 | + spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR); |
|
| 563 | 563 | return false; |
| 564 | 564 | } |
| 565 | 565 | } elseif ($res['location'] and $options['follow_location']) { |
@@ -575,11 +575,11 @@ discard block |
||
| 575 | 575 | $options['datas'] = ''; |
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | - spip_log('recuperer_url recommence ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 578 | + spip_log('recuperer_url recommence '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 579 | 579 | |
| 580 | 580 | return recuperer_url($url, $options); |
| 581 | 581 | } elseif ($res['status'] !== 200) { |
| 582 | - spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant'); |
|
| 582 | + spip_log('HTTP status '.$res['status']." pour $url", 'distant'); |
|
| 583 | 583 | } |
| 584 | 584 | $result['status'] = $res['status']; |
| 585 | 585 | if (isset($res['headers'])) { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | |
| 596 | 596 | // on ne veut que les entetes |
| 597 | 597 | if (!$options['taille_max'] or $options['methode'] == 'HEAD' or $result['status'] == '304') { |
| 598 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($result), 'distant' . _LOG_DEBUG); |
|
| 598 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($result), 'distant'._LOG_DEBUG); |
|
| 599 | 599 | return $result; |
| 600 | 600 | } |
| 601 | 601 | |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | $gz = false; |
| 607 | 607 | if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) { |
| 608 | - $gz = (_DIR_TMP . md5(uniqid(random_int(0, mt_getrandmax()))) . '.tmp.gz'); |
|
| 608 | + $gz = (_DIR_TMP.md5(uniqid(random_int(0, mt_getrandmax()))).'.tmp.gz'); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // si on a pas deja recuperer le contenu par une methode detournee |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | $trace = json_decode(json_encode($result), true); |
| 643 | 643 | $trace['page'] = '...'; |
| 644 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($trace), 'distant' . _LOG_DEBUG); |
|
| 644 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($trace), 'distant'._LOG_DEBUG); |
|
| 645 | 645 | |
| 646 | 646 | return $result; |
| 647 | 647 | } |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | $sig['url'] = $url; |
| 696 | 696 | |
| 697 | 697 | $dir = sous_repertoire(_DIR_CACHE, 'curl'); |
| 698 | - $cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 698 | + $cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 699 | 699 | $sub = sous_repertoire($dir, substr($cache, 0, 2)); |
| 700 | 700 | $cache = "$sub$cache"; |
| 701 | 701 | |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | $fp = false; |
| 750 | 750 | if ($fichier) { |
| 751 | 751 | include_spip('inc/acces'); |
| 752 | - $tmpfile = "$fichier." . creer_uniqid() . '.tmp'; |
|
| 752 | + $tmpfile = "$fichier.".creer_uniqid().'.tmp'; |
|
| 753 | 753 | $fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX); |
| 754 | 754 | if (!$fp and file_exists($fichier)) { |
| 755 | 755 | return filesize($fichier); |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | } |
| 809 | 809 | $result['status'] = intval($r[1]); |
| 810 | 810 | while ($s = trim(fgets($handle, 16384))) { |
| 811 | - $result['headers'][] = $s . "\n"; |
|
| 811 | + $result['headers'][] = $s."\n"; |
|
| 812 | 812 | preg_match(',^([^:]*): *(.*)$,i', $s, $r); |
| 813 | 813 | [, $d, $v] = $r; |
| 814 | 814 | if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) { |
@@ -857,13 +857,13 @@ discard block |
||
| 857 | 857 | |
| 858 | 858 | // on se place tout le temps comme si on etait a la racine |
| 859 | 859 | if (_DIR_RACINE) { |
| 860 | - $d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d); |
|
| 860 | + $d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | $m = md5($source); |
| 864 | 864 | |
| 865 | 865 | return $d |
| 866 | - . substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12) |
|
| 866 | + . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12) |
|
| 867 | 867 | . substr($m, 0, 4) |
| 868 | 868 | . ".$extension"; |
| 869 | 869 | } |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | // Si c'est deja local pas de souci |
| 888 | 888 | if (!tester_url_absolue($source)) { |
| 889 | 889 | if (_DIR_RACINE) { |
| 890 | - $source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source); |
|
| 890 | + $source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | return $source; |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | $ext |
| 906 | 906 | and preg_match(',^\w+$,', $ext) // pas de php?truc=1&... |
| 907 | 907 | and $f = nom_fichier_copie_locale($source, $ext) |
| 908 | - and file_exists(_DIR_RACINE . $f) |
|
| 908 | + and file_exists(_DIR_RACINE.$f) |
|
| 909 | 909 | ) { |
| 910 | 910 | return $f; |
| 911 | 911 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | |
| 914 | 914 | // Si c'est deja dans la table des documents, |
| 915 | 915 | // ramener le nom de sa copie potentielle |
| 916 | - $ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''"); |
|
| 916 | + $ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''"); |
|
| 917 | 917 | |
| 918 | 918 | if ($ext) { |
| 919 | 919 | return nom_fichier_copie_locale($source, $ext); |
@@ -924,9 +924,9 @@ discard block |
||
| 924 | 924 | |
| 925 | 925 | $ext = $path_parts ? $path_parts['extension'] : ''; |
| 926 | 926 | |
| 927 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 927 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 928 | 928 | $f = nom_fichier_copie_locale($source, $ext); |
| 929 | - if (file_exists(_DIR_RACINE . $f)) { |
|
| 929 | + if (file_exists(_DIR_RACINE.$f)) { |
|
| 930 | 930 | return $f; |
| 931 | 931 | } |
| 932 | 932 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | // Ping pour voir si son extension est connue et autorisee |
| 935 | 935 | // avec mise en cache du resultat du ping |
| 936 | 936 | |
| 937 | - $cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source); |
|
| 937 | + $cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source); |
|
| 938 | 938 | if ( |
| 939 | 939 | !@file_exists($cache) |
| 940 | 940 | or !$path_parts = @unserialize(spip_file_get_contents($cache)) |
@@ -944,11 +944,11 @@ discard block |
||
| 944 | 944 | ecrire_fichier($cache, serialize($path_parts)); |
| 945 | 945 | } |
| 946 | 946 | $ext = !empty($path_parts['extension']) ? $path_parts['extension'] : ''; |
| 947 | - if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 947 | + if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 948 | 948 | return nom_fichier_copie_locale($source, $ext); |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR); |
|
| 951 | + spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR); |
|
| 952 | 952 | return null; |
| 953 | 953 | } |
| 954 | 954 | |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | } else { |
| 1048 | 1048 | if ($a['body']) { |
| 1049 | 1049 | $a['extension'] = $extension; |
| 1050 | - $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension); |
|
| 1050 | + $a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension); |
|
| 1051 | 1051 | ecrire_fichier($a['fichier'], $a['body']); |
| 1052 | 1052 | $size_image = @spip_getimagesize($a['fichier']); |
| 1053 | 1053 | $a['largeur'] = intval($size_image[0]); |
@@ -1115,20 +1115,20 @@ discard block |
||
| 1115 | 1115 | !$t |
| 1116 | 1116 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1117 | 1117 | ) { |
| 1118 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1118 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | if ( |
| 1121 | 1121 | !$t |
| 1122 | 1122 | and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m) |
| 1123 | 1123 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext) |
| 1124 | 1124 | ) { |
| 1125 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1125 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | // Autre mime/type (ou text/plain avec fichier d'extension inconnue) |
| 1130 | 1130 | if (!$t) { |
| 1131 | - $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type)); |
|
| 1131 | + $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type)); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) |
@@ -1139,11 +1139,11 @@ discard block |
||
| 1139 | 1139 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1140 | 1140 | ) { |
| 1141 | 1141 | # eviter xxx.3 => 3gp (> SPIP 3) |
| 1142 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1142 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | if ($t) { |
| 1146 | - spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant'); |
|
| 1146 | + spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant'); |
|
| 1147 | 1147 | return $t['extension']; |
| 1148 | 1148 | } else { |
| 1149 | 1149 | # par defaut on retombe sur '.bin' si c'est autorise |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | } |
| 1247 | 1247 | } else { |
| 1248 | 1248 | $scheme = $t['scheme']; |
| 1249 | - $noproxy = $scheme . '://'; |
|
| 1249 | + $noproxy = $scheme.'://'; |
|
| 1250 | 1250 | } |
| 1251 | 1251 | if (isset($t['user'])) { |
| 1252 | 1252 | $user = [$t['user'], $t['pass']]; |
@@ -1260,7 +1260,7 @@ discard block |
||
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | if (!empty($t['query'])) { |
| 1263 | - $path .= '?' . $t['query']; |
|
| 1263 | + $path .= '?'.$t['query']; |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date); |
@@ -1334,29 +1334,29 @@ discard block |
||
| 1334 | 1334 | $proxy_user = ''; |
| 1335 | 1335 | $http_proxy = need_proxy($host); |
| 1336 | 1336 | if ($user) { |
| 1337 | - $user = urlencode($user[0]) . ':' . urlencode($user[1]); |
|
| 1337 | + $user = urlencode($user[0]).':'.urlencode($user[1]); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | $connect = ''; |
| 1341 | 1341 | if ($http_proxy) { |
| 1342 | - if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls','ssl'])) { |
|
| 1343 | - $path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : ''); |
|
| 1344 | - $connect = 'CONNECT ' . $path_host . " $vers\r\n" |
|
| 1342 | + if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls', 'ssl'])) { |
|
| 1343 | + $path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : ''); |
|
| 1344 | + $connect = 'CONNECT '.$path_host." $vers\r\n" |
|
| 1345 | 1345 | . "Host: $path_host\r\n" |
| 1346 | 1346 | . "Proxy-Connection: Keep-Alive\r\n"; |
| 1347 | 1347 | } else { |
| 1348 | - $path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://") |
|
| 1348 | + $path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://") |
|
| 1349 | 1349 | . (!$user ? '' : "$user@") |
| 1350 | - . "$host" . (($port != 80) ? ":$port" : '') . $path; |
|
| 1350 | + . "$host".(($port != 80) ? ":$port" : '').$path; |
|
| 1351 | 1351 | } |
| 1352 | 1352 | $t2 = @parse_url($http_proxy); |
| 1353 | 1353 | $first_host = $t2['host']; |
| 1354 | 1354 | $first_port = ($t2['port'] ?? null) ?: 80; |
| 1355 | 1355 | if ($t2['user'] ?? null) { |
| 1356 | - $proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']); |
|
| 1356 | + $proxy_user = base64_encode($t2['user'].':'.$t2['pass']); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | } else { |
| 1359 | - $first_host = $noproxy . $host; |
|
| 1359 | + $first_host = $noproxy.$host; |
|
| 1360 | 1360 | $first_port = $port; |
| 1361 | 1361 | } |
| 1362 | 1362 | |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | ); |
| 1380 | 1380 | spip_log("Recuperer $path sur $first_host:$first_port par $f (via CONNECT)", 'connect'); |
| 1381 | 1381 | if (!$f) { |
| 1382 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1382 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1383 | 1383 | return $errno; |
| 1384 | 1384 | } |
| 1385 | 1385 | stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | or !count($res = explode(' ', $res)) |
| 1393 | 1393 | or $res[1] !== '200' |
| 1394 | 1394 | ) { |
| 1395 | - spip_log("Echec CONNECT sur $first_host:$first_port", 'connect' . _LOG_INFO_IMPORTANTE); |
|
| 1395 | + spip_log("Echec CONNECT sur $first_host:$first_port", 'connect'._LOG_INFO_IMPORTANTE); |
|
| 1396 | 1396 | fclose($f); |
| 1397 | 1397 | |
| 1398 | 1398 | return false; |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | } while (!$f and $ntry-- and $errno !== 110 and sleep(1)); |
| 1410 | 1410 | spip_log("Recuperer $path sur $first_host:$first_port par $f"); |
| 1411 | 1411 | if (!$f) { |
| 1412 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1412 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1413 | 1413 | |
| 1414 | 1414 | return $errno; |
| 1415 | 1415 | } |
@@ -1419,16 +1419,16 @@ discard block |
||
| 1419 | 1419 | $site = $GLOBALS['meta']['adresse_site'] ?? ''; |
| 1420 | 1420 | |
| 1421 | 1421 | $host_port = $host; |
| 1422 | - if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) { |
|
| 1422 | + if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) { |
|
| 1423 | 1423 | $host_port .= ":$port"; |
| 1424 | 1424 | } |
| 1425 | 1425 | $req = "$method $path $vers\r\n" |
| 1426 | 1426 | . "Host: $host_port\r\n" |
| 1427 | - . 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n" |
|
| 1428 | - . ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n")) |
|
| 1427 | + . 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n" |
|
| 1428 | + . ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n")) |
|
| 1429 | 1429 | . (!$site ? '' : "Referer: $site/$referer\r\n") |
| 1430 | - . (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n")) |
|
| 1431 | - . (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n")) |
|
| 1430 | + . (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n")) |
|
| 1431 | + . (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n")) |
|
| 1432 | 1432 | . (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n") |
| 1433 | 1433 | . (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n"); |
| 1434 | 1434 | |