@@ -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' && preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) { |
| 76 | - $source = substr((string) _DIR_IMG, strlen((string) _DIR_RACINE)) . urldecode($match[1]); |
|
| 76 | + $source = substr((string) _DIR_IMG, strlen((string) _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,17 +113,17 @@ 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 || !$res['length'] && $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 | } 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 || !$res['length']) { |
| 129 | 129 | // si $t c'est sans doute juste un not-modified-since |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | && is_callable($callback_valider_url) |
| 137 | 137 | && !$callback_valider_url($res['url']) |
| 138 | 138 | ) { |
| 139 | - spip_log('copie_locale : url finale ' . $res['url'] . " non valide, on refuse le fichier $localrac_tmp", 'distant' . _LOG_INFO_IMPORTANTE); |
|
| 139 | + spip_log('copie_locale : url finale '.$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant'._LOG_INFO_IMPORTANTE); |
|
| 140 | 140 | @unlink($localrac_tmp); |
| 141 | 141 | return $t ? $local : false; |
| 142 | 142 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | if (!$is_known_host) { |
| 228 | 228 | $host = trim($parsed_url['host'], '.'); |
| 229 | - if (! $ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 229 | + if (!$ip = filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 230 | 230 | $ip = gethostbyname($host); |
| 231 | 231 | if ($ip === $host) { |
| 232 | 232 | // Error condition for gethostbyname() |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $ip = false; |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | - if ($ip && ! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 249 | + if ($ip && !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -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 | |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | foreach ($donnees as $cle => $valeur) { |
| 361 | 361 | if (is_array($valeur)) { |
| 362 | 362 | foreach ($valeur as $val2) { |
| 363 | - $chaines[] = rawurlencode($cle) . '[]=' . rawurlencode((string) $val2); |
|
| 363 | + $chaines[] = rawurlencode($cle).'[]='.rawurlencode((string) $val2); |
|
| 364 | 364 | } |
| 365 | 365 | } else { |
| 366 | - $chaines[] = rawurlencode($cle) . '=' . rawurlencode((string) $valeur); |
|
| 366 | + $chaines[] = rawurlencode($cle).'='.rawurlencode((string) $valeur); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | $chaine = implode('&', $chaines); |
@@ -466,13 +466,13 @@ discard block |
||
| 466 | 466 | $options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - spip_log('recuperer_url ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 469 | + spip_log('recuperer_url '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 470 | 470 | |
| 471 | 471 | // Ajout des en-têtes spécifiques si besoin |
| 472 | 472 | $formatted_data = ''; |
| 473 | 473 | if (!empty($options['headers'])) { |
| 474 | 474 | foreach ($options['headers'] as $champ => $valeur) { |
| 475 | - $formatted_data .= $champ . ': ' . $valeur . "\r\n"; |
|
| 475 | + $formatted_data .= $champ.': '.$valeur."\r\n"; |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | |
@@ -480,9 +480,9 @@ discard block |
||
| 480 | 480 | [$head, $postdata] = prepare_donnees_post($options['datas'], $options['boundary']); |
| 481 | 481 | $head .= $formatted_data; |
| 482 | 482 | if (stripos($head, 'Content-Length:') === false) { |
| 483 | - $head .= 'Content-Length: ' . strlen((string) $postdata) . "\r\n"; |
|
| 483 | + $head .= 'Content-Length: '.strlen((string) $postdata)."\r\n"; |
|
| 484 | 484 | } |
| 485 | - $formatted_data = $head . "\r\n" . $postdata; |
|
| 485 | + $formatted_data = $head."\r\n".$postdata; |
|
| 486 | 486 | if ( |
| 487 | 487 | strlen((string) $postdata) && !$methode_demandee |
| 488 | 488 | ) { |
@@ -495,9 +495,9 @@ discard block |
||
| 495 | 495 | // Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole |
| 496 | 496 | $url = preg_replace(',^feed://,i', 'http://', $url); |
| 497 | 497 | if (!tester_url_absolue($url)) { |
| 498 | - $url = 'http://' . $url; |
|
| 498 | + $url = 'http://'.$url; |
|
| 499 | 499 | } elseif (str_starts_with($url, '//')) { |
| 500 | - $url = 'http:' . $url; |
|
| 500 | + $url = 'http:'.$url; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | $url = url_to_ascii($url); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $options['if_modified_since'] |
| 527 | 527 | ); |
| 528 | 528 | if (!$handle) { |
| 529 | - spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR); |
|
| 529 | + spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR); |
|
| 530 | 530 | |
| 531 | 531 | return false; |
| 532 | 532 | } |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | 'status' => 200, |
| 557 | 557 | ]; |
| 558 | 558 | } else { |
| 559 | - spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR); |
|
| 559 | + spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR); |
|
| 560 | 560 | return false; |
| 561 | 561 | } |
| 562 | 562 | } elseif ($res['location'] && $options['follow_location']) { |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | $options['methode'] = 'GET'; |
| 574 | 574 | $options['datas'] = ''; |
| 575 | 575 | } |
| 576 | - spip_log('recuperer_url recommence ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG); |
|
| 576 | + spip_log('recuperer_url recommence '.$options['methode']." sur $url", 'distant'._LOG_DEBUG); |
|
| 577 | 577 | |
| 578 | 578 | return recuperer_url($url, $options); |
| 579 | 579 | } elseif ($res['status'] !== 200) { |
| 580 | - spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant'); |
|
| 580 | + spip_log('HTTP status '.$res['status']." pour $url", 'distant'); |
|
| 581 | 581 | } |
| 582 | 582 | $result['status'] = $res['status']; |
| 583 | 583 | 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'] || $options['methode'] == 'HEAD' || $result['status'] == '304') { |
| 599 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($result, JSON_THROW_ON_ERROR), 'distant' . _LOG_DEBUG); |
|
| 599 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($result, JSON_THROW_ON_ERROR), '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", (string) $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 n'a pas deja récupéré le contenu par une methode detournée |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | $trace = json_decode(json_encode($result, JSON_THROW_ON_ERROR), true, 512, JSON_THROW_ON_ERROR); |
| 651 | 651 | } catch (JsonException $e) { |
| 652 | 652 | $trace = []; |
| 653 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), _LOG_ERREUR); |
|
| 653 | + spip_log('Failed to parse Json data : '.$e->getMessage(), _LOG_ERREUR); |
|
| 654 | 654 | } |
| 655 | 655 | $trace['page'] = '...'; |
| 656 | - spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($trace, JSON_THROW_ON_ERROR), 'distant' . _LOG_DEBUG); |
|
| 656 | + spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($trace, JSON_THROW_ON_ERROR), 'distant'._LOG_DEBUG); |
|
| 657 | 657 | |
| 658 | 658 | return $result; |
| 659 | 659 | } |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $sig['url'] = $url; |
| 708 | 708 | |
| 709 | 709 | $dir = sous_repertoire(_DIR_CACHE, 'curl'); |
| 710 | - $cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 710 | + $cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80); |
|
| 711 | 711 | $sub = sous_repertoire($dir, substr($cache, 0, 2)); |
| 712 | 712 | $cache = "$sub$cache"; |
| 713 | 713 | |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $fp = false; |
| 762 | 762 | if ($fichier) { |
| 763 | 763 | include_spip('inc/acces'); |
| 764 | - $tmpfile = "$fichier." . creer_uniqid() . '.tmp'; |
|
| 764 | + $tmpfile = "$fichier.".creer_uniqid().'.tmp'; |
|
| 765 | 765 | $fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX); |
| 766 | 766 | if (!$fp && file_exists($fichier)) { |
| 767 | 767 | return filesize($fichier); |
@@ -850,11 +850,11 @@ discard block |
||
| 850 | 850 | } |
| 851 | 851 | $result['status'] = (int) $r[1]; |
| 852 | 852 | while ($s = trim(fgets($handle, 16384))) { |
| 853 | - $result['headers'][] = $s . "\n"; |
|
| 853 | + $result['headers'][] = $s."\n"; |
|
| 854 | 854 | preg_match(',^([^:]*): *(.*)$,i', $s, $r); |
| 855 | 855 | [, $d, $v] = $r; |
| 856 | 856 | $d = strtolower(trim($d)); |
| 857 | - if ( $d === 'location' && $result['status'] >= 300 && $result['status'] < 400) { |
|
| 857 | + if ($d === 'location' && $result['status'] >= 300 && $result['status'] < 400) { |
|
| 858 | 858 | $result['location'] = $v; |
| 859 | 859 | } elseif ($d === 'last-modified') { |
| 860 | 860 | $result['last_modified'] = strtotime($v); |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | |
| 903 | 903 | // on se place tout le temps comme si on était a la racine |
| 904 | 904 | if (_DIR_RACINE) { |
| 905 | - $d = preg_replace(',^' . preg_quote((string) _DIR_RACINE, ',') . ',', '', (string) $d); |
|
| 905 | + $d = preg_replace(',^'.preg_quote((string) _DIR_RACINE, ',').',', '', (string) $d); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | $m = md5($source); |
@@ -910,18 +910,18 @@ discard block |
||
| 910 | 910 | $filename = |
| 911 | 911 | $d |
| 912 | 912 | . substr(preg_replace(',[^\w-],', '', basename($source, $extension)), 0, 16) |
| 913 | - . '-' . substr($m, 0, 8) |
|
| 913 | + . '-'.substr($m, 0, 8) |
|
| 914 | 914 | . ".$extension"; |
| 915 | 915 | |
| 916 | 916 | // ancien nommage des fichiers distants : renommer le fichier a la volee si besoin pour eviter de dupliquer les caches |
| 917 | 917 | $legacy_filename = |
| 918 | 918 | $d |
| 919 | - . substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12) |
|
| 919 | + . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12) |
|
| 920 | 920 | . substr($m, 0, 4) |
| 921 | 921 | . ".$extension"; |
| 922 | 922 | |
| 923 | - if (file_exists(_DIR_RACINE . $legacy_filename)) { |
|
| 924 | - @rename(_DIR_RACINE . $legacy_filename, $filename); |
|
| 923 | + if (file_exists(_DIR_RACINE.$legacy_filename)) { |
|
| 924 | + @rename(_DIR_RACINE.$legacy_filename, $filename); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | return $filename; |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | // Si c'est deja local pas de souci |
| 947 | 947 | if (!tester_url_absolue($source)) { |
| 948 | 948 | if (_DIR_RACINE) { |
| 949 | - $source = preg_replace(',^' . preg_quote((string) _DIR_RACINE, ',') . ',', '', $source); |
|
| 949 | + $source = preg_replace(',^'.preg_quote((string) _DIR_RACINE, ',').',', '', $source); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | return $source; |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | $ext |
| 965 | 965 | && preg_match(',^\w+$,', $ext) |
| 966 | 966 | && ($f = nom_fichier_copie_locale($source, $ext)) |
| 967 | - && file_exists(_DIR_RACINE . $f) |
|
| 967 | + && file_exists(_DIR_RACINE.$f) |
|
| 968 | 968 | ) { |
| 969 | 969 | return $f; |
| 970 | 970 | } |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | // Si c'est deja dans la table des documents, |
| 974 | 974 | // ramener le nom de sa copie potentielle |
| 975 | - $ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''"); |
|
| 975 | + $ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''"); |
|
| 976 | 976 | |
| 977 | 977 | if ($ext) { |
| 978 | 978 | return nom_fichier_copie_locale($source, $ext); |
@@ -983,9 +983,9 @@ discard block |
||
| 983 | 983 | |
| 984 | 984 | $ext = $path_parts ? $path_parts['extension'] : ''; |
| 985 | 985 | |
| 986 | - if ($ext && sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 986 | + if ($ext && sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 987 | 987 | $f = nom_fichier_copie_locale($source, $ext); |
| 988 | - if (file_exists(_DIR_RACINE . $f)) { |
|
| 988 | + if (file_exists(_DIR_RACINE.$f)) { |
|
| 989 | 989 | return $f; |
| 990 | 990 | } |
| 991 | 991 | } |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | // Ping pour voir si son extension est connue et autorisee |
| 994 | 994 | // avec mise en cache du resultat du ping |
| 995 | 995 | |
| 996 | - $cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source); |
|
| 996 | + $cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source); |
|
| 997 | 997 | if ( |
| 998 | 998 | !@file_exists($cache) |
| 999 | 999 | || !($path_parts = @unserialize(spip_file_get_contents($cache))) |
@@ -1003,11 +1003,11 @@ discard block |
||
| 1003 | 1003 | ecrire_fichier($cache, serialize($path_parts)); |
| 1004 | 1004 | } |
| 1005 | 1005 | $ext = empty($path_parts['extension']) ? '' : $path_parts['extension']; |
| 1006 | - if ($ext && sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) { |
|
| 1006 | + if ($ext && sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) { |
|
| 1007 | 1007 | return nom_fichier_copie_locale($source, $ext); |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR); |
|
| 1010 | + spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR); |
|
| 1011 | 1011 | return null; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | } else { |
| 1110 | 1110 | if ($a['body']) { |
| 1111 | 1111 | $a['extension'] = corriger_extension($extension); |
| 1112 | - $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension); |
|
| 1112 | + $a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension); |
|
| 1113 | 1113 | ecrire_fichier($a['fichier'], $a['body']); |
| 1114 | 1114 | $size_image = @spip_getimagesize($a['fichier']); |
| 1115 | 1115 | $a['largeur'] = (int) $size_image[0]; |
@@ -1181,20 +1181,20 @@ discard block |
||
| 1181 | 1181 | $t = null; |
| 1182 | 1182 | if (in_array($mime_type, ['text/plain', '', 'application/octet-stream'])) { |
| 1183 | 1183 | if (!$t && preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)) { |
| 1184 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1184 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | if ( |
| 1187 | 1187 | !$t |
| 1188 | 1188 | && preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m) |
| 1189 | 1189 | && preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext) |
| 1190 | 1190 | ) { |
| 1191 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1191 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | // Autre mime/type (ou text/plain avec fichier d'extension inconnue) |
| 1196 | 1196 | if (!$t) { |
| 1197 | - $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type)); |
|
| 1197 | + $t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type)); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) |
@@ -1205,11 +1205,11 @@ discard block |
||
| 1205 | 1205 | && preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext) |
| 1206 | 1206 | ) { |
| 1207 | 1207 | # eviter xxx.3 => 3gp (> SPIP 3) |
| 1208 | - $t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1208 | + $t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text')); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | if ($t) { |
| 1212 | - spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant'); |
|
| 1212 | + spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant'); |
|
| 1213 | 1213 | return $t['extension']; |
| 1214 | 1214 | } else { |
| 1215 | 1215 | # par defaut on retombe sur '.bin' si c'est autorise |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | } |
| 1313 | 1313 | } else { |
| 1314 | 1314 | $scheme = $t['scheme']; |
| 1315 | - $noproxy = $scheme . '://'; |
|
| 1315 | + $noproxy = $scheme.'://'; |
|
| 1316 | 1316 | } |
| 1317 | 1317 | if (isset($t['user'])) { |
| 1318 | 1318 | // user et pass doivent être passés en urlencodé dans l'URL, on redecode ici |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | if (!empty($t['query'])) { |
| 1330 | - $path .= '?' . $t['query']; |
|
| 1330 | + $path .= '?'.$t['query']; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date); |
@@ -1401,29 +1401,29 @@ discard block |
||
| 1401 | 1401 | $proxy_user = ''; |
| 1402 | 1402 | $http_proxy = need_proxy($host); |
| 1403 | 1403 | if ($user) { |
| 1404 | - $user = urlencode((string) $user[0]) . ':' . urlencode((string) $user[1]); |
|
| 1404 | + $user = urlencode((string) $user[0]).':'.urlencode((string) $user[1]); |
|
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | 1407 | $connect = ''; |
| 1408 | 1408 | if ($http_proxy) { |
| 1409 | - if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') && in_array($scheme, ['tls','ssl'])) { |
|
| 1410 | - $path_host = ($user ? "$user@" : '') . $host . (($port != 80) ? ":$port" : ''); |
|
| 1411 | - $connect = 'CONNECT ' . $path_host . " $vers\r\n" |
|
| 1409 | + if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') && in_array($scheme, ['tls', 'ssl'])) { |
|
| 1410 | + $path_host = ($user ? "$user@" : '').$host.(($port != 80) ? ":$port" : ''); |
|
| 1411 | + $connect = 'CONNECT '.$path_host." $vers\r\n" |
|
| 1412 | 1412 | . "Host: $path_host\r\n" |
| 1413 | 1413 | . "Proxy-Connection: Keep-Alive\r\n"; |
| 1414 | 1414 | } else { |
| 1415 | - $path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://") |
|
| 1415 | + $path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://") |
|
| 1416 | 1416 | . ($user ? "$user@" : '') |
| 1417 | - . "$host" . (($port != 80) ? ":$port" : '') . $path; |
|
| 1417 | + . "$host".(($port != 80) ? ":$port" : '').$path; |
|
| 1418 | 1418 | } |
| 1419 | 1419 | $t2 = @parse_url($http_proxy); |
| 1420 | 1420 | $first_host = $t2['host']; |
| 1421 | 1421 | $first_port = ($t2['port'] ?? null) ?: 80; |
| 1422 | 1422 | if ($t2['user'] ?? null) { |
| 1423 | - $proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']); |
|
| 1423 | + $proxy_user = base64_encode($t2['user'].':'.$t2['pass']); |
|
| 1424 | 1424 | } |
| 1425 | 1425 | } else { |
| 1426 | - $first_host = $noproxy . $host; |
|
| 1426 | + $first_host = $noproxy.$host; |
|
| 1427 | 1427 | $first_port = $port; |
| 1428 | 1428 | } |
| 1429 | 1429 | |
@@ -1446,7 +1446,7 @@ discard block |
||
| 1446 | 1446 | ); |
| 1447 | 1447 | spip_log("Recuperer $path sur $first_host:$first_port par $f (via CONNECT)", 'connect'); |
| 1448 | 1448 | if (!$f) { |
| 1449 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1449 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1450 | 1450 | return $errno; |
| 1451 | 1451 | } |
| 1452 | 1452 | stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | || ($res = explode(' ', $res)) === [] |
| 1460 | 1460 | || $res[1] !== '200' |
| 1461 | 1461 | ) { |
| 1462 | - spip_log("Echec CONNECT sur $first_host:$first_port", 'connect' . _LOG_INFO_IMPORTANTE); |
|
| 1462 | + spip_log("Echec CONNECT sur $first_host:$first_port", 'connect'._LOG_INFO_IMPORTANTE); |
|
| 1463 | 1463 | fclose($f); |
| 1464 | 1464 | |
| 1465 | 1465 | return false; |
@@ -1476,7 +1476,7 @@ discard block |
||
| 1476 | 1476 | } while (!$f && $ntry-- && $errno !== 110 && sleep(1)); |
| 1477 | 1477 | spip_log("Recuperer $path sur $first_host:$first_port par $f"); |
| 1478 | 1478 | if (!$f) { |
| 1479 | - spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR); |
|
| 1479 | + spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR); |
|
| 1480 | 1480 | |
| 1481 | 1481 | return $errno; |
| 1482 | 1482 | } |
@@ -1486,16 +1486,16 @@ discard block |
||
| 1486 | 1486 | $site = $GLOBALS['meta']['adresse_site'] ?? ''; |
| 1487 | 1487 | |
| 1488 | 1488 | $host_port = $host; |
| 1489 | - if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) { |
|
| 1489 | + if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) { |
|
| 1490 | 1490 | $host_port .= ":$port"; |
| 1491 | 1491 | } |
| 1492 | 1492 | $req = "$method $path $vers\r\n" |
| 1493 | 1493 | . "Host: $host_port\r\n" |
| 1494 | - . 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n" |
|
| 1495 | - . ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n")) |
|
| 1494 | + . 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n" |
|
| 1495 | + . ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n")) |
|
| 1496 | 1496 | . ($site ? "Referer: $site/$referer\r\n" : '') |
| 1497 | - . ($date ? 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n") : '') |
|
| 1498 | - . ($user ? 'Authorization: Basic ' . base64_encode(urldecode($user)) . "\r\n" : '') |
|
| 1497 | + . ($date ? 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n") : '') |
|
| 1498 | + . ($user ? 'Authorization: Basic '.base64_encode(urldecode($user))."\r\n" : '') |
|
| 1499 | 1499 | . ($proxy_user ? "Proxy-Authorization: Basic $proxy_user\r\n" : '') |
| 1500 | 1500 | . (strpos($vers, '1.1') ? "Keep-Alive: 300\r\nConnection: keep-alive\r\n" : ''); |
| 1501 | 1501 | |