add method getStreamContext()

This commit is contained in:
Uwe Steinmann 2025-09-03 11:43:57 +02:00
parent c25f0a32be
commit 7d81f5b0f8

View File

@ -462,6 +462,29 @@ function getFilenameByDocname($content) { /* {{{ */
return mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
} /* }}} */
function getStreamContext($proxyurl, $proxyuser, $proxypass) { /* {{{ */
if(!$proxyurl)
return null;
$url = parse_url($proxyurl);
$opts = [
$url['scheme'] => [
'proxy' => 'tcp://'.$url['host'].($url['port'] ? ':'.$url['port'] : ''),
'request_fulluri' => true,
]
];
if($proxyuser && $proxypass) {
$auth = base64_encode($proxyurl.':'.$this->proxypass);
$opts[$url['scheme']] = [
'header' => [
'Proxy-Authorization: Basic '.$auth
]
];
}
$context = stream_context_create($opts);
return $context;
} /* }}} */
function getLogger($prefix='', $mask=PEAR_LOG_INFO) { /* {{{ */
global $settings;