@@ -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', 2_097_152); |
@@ -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?:', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // si c'est la protection de soi-meme, retourner le path |
| 74 | 74 | if ($mode !== 'force' and preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) { |
| 75 | - $source = substr(_DIR_IMG, strlen(_DIR_RACINE)) . urldecode($match[1]); |
|
| 75 | + $source = substr(_DIR_IMG, strlen(_DIR_RACINE)).urldecode($match[1]); |
|
| 76 | 76 | |
| 77 | 77 | return @file_exists($source) ? $source : false; |
| 78 | 78 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $localrac = _DIR_RACINE . $local; |
|
| 95 | + $localrac = _DIR_RACINE.$local; |
|
| 96 | 96 | $t = ($mode === 'force') ? false : @file_exists($localrac); |
| 97 | 97 | |
| 98 | 98 | // test d'existence du fichier |
@@ -112,18 +112,18 @@ discard block |
||
| 112 | 112 | if (!$taille_max) { |
| 113 | 113 | $taille_max = _COPIE_LOCALE_MAX_SIZE; |
| 114 | 114 | } |
| 115 | - $localrac_tmp = $localrac . '.tmp'; |
|
| 115 | + $localrac_tmp = $localrac.'.tmp'; |
|
| 116 | 116 | $res = recuperer_url( |
| 117 | 117 | $source, |
| 118 | 118 | ['file' => $localrac_tmp, 'taille_max' => $taille_max, 'if_modified_since' => $t ? filemtime($localrac) : ''] |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | if (!$res or (!$res['length'] and $res['status'] != 304)) { |
| 122 | - spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : " . ($res ? $res['status'] : '-'), 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 122 | + spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : ".($res ? $res['status'] : '-'), 'distant'._LOG_INFO_IMPORTANTE); |
|
| 123 | 123 | @unlink($localrac_tmp); |
| 124 | 124 | } |
| 125 | 125 | else { |
| 126 | - spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille " . $res['length'] . ' status ' . $res['status'], 'distant'); |
|
| 126 | + spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille ".$res['length'].' status '.$res['status'], 'distant'); |
|
| 127 | 127 | } |
| 128 | 128 | if (!$res or !$res['length']) { |
| 129 | 129 | // si $t c'est sans doute juste un not-modified-since |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | if ($callback_valider_url |
| 135 | 135 | and is_callable($callback_valider_url) |
| 136 | 136 | and !$callback_valider_url($res['url'])) { |
| 137 | - spip_log("copie_locale : url finale ".$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 137 | + spip_log("copie_locale : url finale ".$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant'._LOG_INFO_IMPORTANTE); |
|
| 138 | 138 | @unlink($localrac_tmp); |
| 139 | 139 | return $t ? $local : false; |
| 140 | 140 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | if (!$is_known_host) { |
| 227 | 227 | $host = trim($parsed_url['host'], '.'); |
| 228 | - if (! $ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 228 | + if (!$ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 229 | 229 | $ip = gethostbyname($host); |
| 230 | 230 | if ($ip === $host) { |
| 231 | 231 | // Error condition for gethostbyname() |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | if ($ip) { |
| 249 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 249 | + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | $port = $parsed_url['port']; |
| 260 | - if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 260 | + if ($port === 80 or $port === 443 or $port === 8080) { |
|
| 261 | 261 | return $url; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | if ($taille > 500) { |
| 330 | - $boundary = substr(md5(random_int(0, mt_getrandmax()) . 'spip'), 0, 8); |
|
| 330 | + $boundary = substr(md5(random_int(0, mt_getrandmax()).'spip'), 0, 8); |
|
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | } else { |
| 357 | 357 | // fabrique une chaine HTTP simple pour un POST |
| 358 | - $entete = 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; |
|
| 358 | + $entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n"; |
|
| 359 | 359 | $chaine = []; |
| 360 | 360 | if (is_array($donnees)) { |
| 361 | 361 | foreach ($donnees as $cle => $valeur) { |
| 362 | 362 | if (is_array($valeur)) { |
| 363 | 363 | foreach ($valeur as $val2) { |
| 364 | - $chaine[] = rawurlencode($cle) . '[]=' . rawurlencode($val2); |
|
| 364 | + $chaine[] = rawurlencode($cle).'[]='.rawurlencode($val2); |
|
| 365 | 365 | } |
| 366 | 366 | } else { |
| 367 | - $chaine[] = rawurlencode($cle) . '=' . rawurlencode($valeur); |
|
| 367 | + $chaine[] = rawurlencode($cle).'='.rawurlencode($valeur); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | $chaine = implode('&', $chaine); |
@@ -469,13 +469,13 @@ discard block |
||
| 469 | 469 | $options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - spip_log('recuperer_url ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 472 | + spip_log('recuperer_url '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 473 | 473 | |
| 474 | 474 | // Ajout des en-têtes spécifiques si besoin |
| 475 | 475 | $formatted_data = ''; |
| 476 | 476 | if (!empty($options['headers'])) { |
| 477 | 477 | foreach ($options['headers'] as $champ => $valeur) { |
| 478 | - $formatted_data .= $champ . ': ' . $valeur . "\r\n"; |
|
| 478 | + $formatted_data .= $champ.': '.$valeur."\r\n"; |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
@@ -483,9 +483,9 @@ discard block |
||
| 483 | 483 | [$head, $postdata] = prepare_donnees_post($options['datas'], $options['boundary']); |
| 484 | 484 | $head .= $formatted_data; |
| 485 | 485 | if (stripos($head, 'Content-Length:') === false) { |
| 486 | - $head .= 'Content-Length: ' . strlen($postdata) . "\r\n"; |
|
| 486 | + $head .= 'Content-Length: '.strlen($postdata)."\r\n"; |
|
| 487 | 487 | } |
| 488 | - $formatted_data = $head . "\r\n" . $postdata; |
|
| 488 | + $formatted_data = $head."\r\n".$postdata; |
|
| 489 | 489 | if ( |
| 490 | 490 | strlen($postdata) |
| 491 | 491 | and !$methode_demandee |
@@ -499,9 +499,9 @@ discard block |
||
| 499 | 499 | // Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole |
| 500 | 500 | $url = preg_replace(',^feed://,i', 'http://', $url); |
| 501 | 501 | if (!tester_url_absolue($url)) { |
| 502 | - $url = 'http://' . $url; |
|
| 502 | + $url = 'http://'.$url; |
|
| 503 | 503 | } elseif (strncmp($url, '//', 2) == 0) { |
| 504 | - $url = 'http:' . $url; |
|
| 504 | + $url = 'http:'.$url; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | $url = url_to_ascii($url); |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | $options['if_modified_since'] |
| 531 | 531 | ); |
| 532 | 532 | if (!$handle) { |
| 533 | - spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR); |
|
| 533 | + spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR); |
|
| 534 | 534 | |
| 535 | 535 | return false; |
| 536 | 536 | } |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | 'status' => 200, |
| 561 | 561 | ]; |
| 562 | 562 | } else { |
| 563 | - spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR); |
|
| 563 | + spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR); |
|
| 564 | 564 | return false; |
| 565 | 565 | } |
| 566 | 566 | } elseif ($res['location'] and $options['follow_location']) { |
@@ -576,11 +576,11 @@ discard block |
||
| 576 | 576 | $options['datas'] = ''; |
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | - spip_log('recuperer_url recommence ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 579 | + spip_log('recuperer_url recommence '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 580 | 580 | |
| 581 | 581 | return recuperer_url($url, $options); |
| 582 | 582 | } elseif ($res['status'] !== 200) { |
| 583 | - spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant'); |
|
| 583 | + spip_log('HTTP status '.$res['status']." pour $url", 'distant'); |
|
| 584 | 584 | } |
| 585 | 585 | $result['status'] = $res['status']; |
| 586 | 586 | if (isset($res['headers'])) { |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | // on ne veut que les entetes |
| 598 | 598 | if (!$options['taille_max'] or $options['methode'] == 'HEAD' or $result['status'] == '304') { |
| 599 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($result), 'distant' . _LOG_DEBUG); |
|
| 599 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($result), 'distant'._LOG_DEBUG); |
|
| 600 | 600 | return $result; |
| 601 | 601 | } |
| 602 | 602 | |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | $gz = false; |
| 608 | 608 | if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) { |
| 609 | - $gz = (_DIR_TMP . md5(uniqid(random_int(0, mt_getrandmax()))) . '.tmp.gz'); |
|
| 609 | + $gz = (_DIR_TMP.md5(uniqid(random_int(0, mt_getrandmax()))).'.tmp.gz'); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | // si on a pas deja recuperer le contenu par une methode detournee |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | $trace = json_decode(json_encode($result), true); |
| 644 | 644 | $trace['page'] = '...'; |
| 645 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($trace), 'distant' . _LOG_DEBUG); |
|
| 645 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($trace), 'distant'._LOG_DEBUG); |
|
| 646 | 646 | |
| 647 | 647 | return $result; |
| 648 | 648 | } |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | $sig['url'] = $url; |
| 697 | 697 | |
| 698 | 698 | $dir = sous_repertoire(_DIR_CACHE, 'curl'); |
| 699 | - $cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 699 | + $cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 700 | 700 | $sub = sous_repertoire($dir, substr($cache, 0, 2)); |
| 701 | 701 | $cache = "$sub$cache"; |
| 702 | 702 | |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | $fp = false; |
| 751 | 751 | if ($fichier) { |
| 752 | 752 | include_spip('inc/acces'); |
| 753 | - $tmpfile = "$fichier." . creer_uniqid() . '.tmp'; |
|
| 753 | + $tmpfile = "$fichier.".creer_uniqid().'.tmp'; |
|
| 754 | 754 | $fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX); |
| 755 | 755 | if (!$fp and file_exists($fichier)) { |
| 756 | 756 | return filesize($fichier); |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | } |
| 810 | 810 | $result['status'] = intval($r[1]); |
| 811 | 811 | while ($s = trim(fgets($handle, 16384))) { |
| 812 | - $result['headers'][] = $s . "\n"; |
|
| 812 | + $result['headers'][] = $s."\n"; |
|
| 813 | 813 | preg_match(',^([^:]*): *(.*)$,i', $s, $r); |
| 814 | 814 | [, $d, $v] = $r; |
| 815 | 815 | if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) { |
@@ -858,13 +858,13 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | // on se place tout le temps comme si on etait a la racine |
| 860 | 860 | if (_DIR_RACINE) { |
| 861 | - $d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d); |
|
| 861 | + $d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | $m = md5($source); |
| 865 | 865 | |
| 866 | 866 | return $d |
| 867 | - . substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12) |
|
| 867 | + . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12) |
|
| 868 | 868 | . substr($m, 0, 4) |
| 869 | 869 | . ".$extension"; |
| 870 | 870 | } |
@@ -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,10 +944,10 @@ 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 | - spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR); |
|
| 950 | + spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | } else { |
| 1044 | 1044 | if ($a['body']) { |
| 1045 | 1045 | $a['extension'] = $extension; |
| 1046 | - $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension); |
|
| 1046 | + $a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension); |
|
| 1047 | 1047 | ecrire_fichier($a['fichier'], $a['body']); |
| 1048 | 1048 | $size_image = @spip_getimagesize($a['fichier']); |
| 1049 | 1049 | $a['largeur'] = intval($size_image[0]); |
@@ -1111,20 +1111,20 @@ discard block |
||
| 1111 | 1111 | !$t |
| 1112 | 1112 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1113 | 1113 | ) { |
| 1114 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1114 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | if ( |
| 1117 | 1117 | !$t |
| 1118 | 1118 | and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m) |
| 1119 | 1119 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext) |
| 1120 | 1120 | ) { |
| 1121 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1121 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | // Autre mime/type (ou text/plain avec fichier d'extension inconnue) |
| 1126 | 1126 | if (!$t) { |
| 1127 | - $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type)); |
|
| 1127 | + $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type)); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | 1130 | // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) |
@@ -1135,11 +1135,11 @@ discard block |
||
| 1135 | 1135 | and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1136 | 1136 | ) { |
| 1137 | 1137 | # eviter xxx.3 => 3gp (> SPIP 3) |
| 1138 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1138 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | if ($t) { |
| 1142 | - spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant'); |
|
| 1142 | + spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant'); |
|
| 1143 | 1143 | return $t['extension']; |
| 1144 | 1144 | } else { |
| 1145 | 1145 | # par defaut on retombe sur '.bin' si c'est autorise |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | } |
| 1243 | 1243 | } else { |
| 1244 | 1244 | $scheme = $t['scheme']; |
| 1245 | - $noproxy = $scheme . '://'; |
|
| 1245 | + $noproxy = $scheme.'://'; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | if (isset($t['user'])) { |
| 1248 | 1248 | $user = [$t['user'], $t['pass']]; |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | if (!empty($t['query'])) { |
| 1259 | - $path .= '?' . $t['query']; |
|
| 1259 | + $path .= '?'.$t['query']; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date); |
@@ -1330,29 +1330,29 @@ discard block |
||
| 1330 | 1330 | $proxy_user = ''; |
| 1331 | 1331 | $http_proxy = need_proxy($host); |
| 1332 | 1332 | if ($user) { |
| 1333 | - $user = urlencode($user[0]) . ':' . urlencode($user[1]); |
|
| 1333 | + $user = urlencode($user[0]).':'.urlencode($user[1]); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | $connect = ''; |
| 1337 | 1337 | if ($http_proxy) { |
| 1338 | - if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls','ssl'])) { |
|
| 1339 | - $path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : ''); |
|
| 1340 | - $connect = 'CONNECT ' . $path_host . " $vers\r\n" |
|
| 1338 | + if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls', 'ssl'])) { |
|
| 1339 | + $path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : ''); |
|
| 1340 | + $connect = 'CONNECT '.$path_host." $vers\r\n" |
|
| 1341 | 1341 | . "Host: $path_host\r\n" |
| 1342 | 1342 | . "Proxy-Connection: Keep-Alive\r\n"; |
| 1343 | 1343 | } else { |
| 1344 | - $path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://") |
|
| 1344 | + $path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://") |
|
| 1345 | 1345 | . (!$user ? '' : "$user@") |
| 1346 | - . "$host" . (($port != 80) ? ":$port" : '') . $path; |
|
| 1346 | + . "$host".(($port != 80) ? ":$port" : '').$path; |
|
| 1347 | 1347 | } |
| 1348 | 1348 | $t2 = @parse_url($http_proxy); |
| 1349 | 1349 | $first_host = $t2['host']; |
| 1350 | 1350 | $port = ($t2['port'] ?? null) ?: 80; |
| 1351 | 1351 | if ($t2['user'] ?? null) { |
| 1352 | - $proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']); |
|
| 1352 | + $proxy_user = base64_encode($t2['user'].':'.$t2['pass']); |
|
| 1353 | 1353 | } |
| 1354 | 1354 | } else { |
| 1355 | - $first_host = $noproxy . $host; |
|
| 1355 | + $first_host = $noproxy.$host; |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | if ($connect) { |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | ); |
| 1375 | 1375 | spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", 'connect'); |
| 1376 | 1376 | if (!$f) { |
| 1377 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1377 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1378 | 1378 | return $errno; |
| 1379 | 1379 | } |
| 1380 | 1380 | stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | or !count($res = explode(' ', $res)) |
| 1388 | 1388 | or $res[1] !== '200' |
| 1389 | 1389 | ) { |
| 1390 | - spip_log("Echec CONNECT sur $first_host:$port", 'connect' . _LOG_INFO_IMPORTANTE); |
|
| 1390 | + spip_log("Echec CONNECT sur $first_host:$port", 'connect'._LOG_INFO_IMPORTANTE); |
|
| 1391 | 1391 | fclose($f); |
| 1392 | 1392 | |
| 1393 | 1393 | return false; |
@@ -1404,7 +1404,7 @@ discard block |
||
| 1404 | 1404 | } while (!$f and $ntry-- and $errno !== 110 and sleep(1)); |
| 1405 | 1405 | spip_log("Recuperer $path sur $first_host:$port par $f"); |
| 1406 | 1406 | if (!$f) { |
| 1407 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1407 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1408 | 1408 | |
| 1409 | 1409 | return $errno; |
| 1410 | 1410 | } |
@@ -1414,16 +1414,16 @@ discard block |
||
| 1414 | 1414 | $site = $GLOBALS['meta']['adresse_site'] ?? ''; |
| 1415 | 1415 | |
| 1416 | 1416 | $host_port = $host; |
| 1417 | - if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) { |
|
| 1417 | + if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) { |
|
| 1418 | 1418 | $host_port .= ":$port"; |
| 1419 | 1419 | } |
| 1420 | 1420 | $req = "$method $path $vers\r\n" |
| 1421 | 1421 | . "Host: $host_port\r\n" |
| 1422 | - . 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n" |
|
| 1423 | - . ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n")) |
|
| 1422 | + . 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n" |
|
| 1423 | + . ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n")) |
|
| 1424 | 1424 | . (!$site ? '' : "Referer: $site/$referer\r\n") |
| 1425 | - . (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n")) |
|
| 1426 | - . (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n")) |
|
| 1425 | + . (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n")) |
|
| 1426 | + . (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n")) |
|
| 1427 | 1427 | . (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n") |
| 1428 | 1428 | . (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n"); |
| 1429 | 1429 | |