Added proxy support

This commit is contained in:
pezcurrel 2024-08-21 10:17:04 +02:00
parent 6b3d9153a1
commit 1cf437ea2c

View file

@ -4,7 +4,7 @@ function curlprogress($curli,$dlsz=0,$dled=0,$ulsz=0,$uled=0) {
// echo "DL: ${dled}; UL: ${uled}\n";
}
function gurl($url,$conntimeout=5,$functimeout=10,$headers=[]) {
function gurl($url,$conntimeout=5,$functimeout=10,$headers=[],$proxy=null) {
$curli=curl_init();
/* curl_setopt($curli,CURLOPT_NOPROGRESS,false);
curl_setopt($curli,CURLOPT_PROGRESSFUNCTION,'curlprogress');*/
@ -17,6 +17,10 @@ function gurl($url,$conntimeout=5,$functimeout=10,$headers=[]) {
curl_setopt($curli,CURLOPT_HEADER,true);
curl_setopt($curli,CURLOPT_ENCODING,'');
curl_setopt($curli,CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0');
if (!is_null($proxy)) {
curl_setopt($curli,CURLOPT_PROXY,$proxy);
curl_setopt($curli,CURLOPT_PROXYTYPE,CURLPROXY_SOCKS5);
}
$gheaders='';
$ecode=false;
$emsg=false;