Made certain “conntimeout” and “functimeout” get passed as integers to curl; added firefox 121.0 user agent as user agent; added an unused curlprogess function, just so
This commit is contained in:
parent
18a3f13ed6
commit
091a7785b2
1 changed files with 9 additions and 5 deletions
|
@ -1,18 +1,22 @@
|
|||
<?php
|
||||
|
||||
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=[]) {
|
||||
$curli=curl_init();
|
||||
// i 2 qui sotto servono a far sì che ctrl+c sia intercettato a monte
|
||||
/*curl_setopt($curli,CURLOPT_NOPROGRESS,false);
|
||||
curl_setopt($curli,CURLOPT_PROGRESSFUNCTION,function($curli,10,10,10,10){});*/
|
||||
/* curl_setopt($curli,CURLOPT_NOPROGRESS,false);
|
||||
curl_setopt($curli,CURLOPT_PROGRESSFUNCTION,'curlprogress');*/
|
||||
curl_setopt($curli,CURLOPT_URL,$url);
|
||||
curl_setopt($curli,CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curli,CURLOPT_FAILONERROR,true);
|
||||
curl_setopt($curli,CURLOPT_CONNECTTIMEOUT,$conntimeout);
|
||||
curl_setopt($curli,CURLOPT_TIMEOUT,$functimeout);
|
||||
curl_setopt($curli,CURLOPT_CONNECTTIMEOUT,$conntimeout+0);
|
||||
curl_setopt($curli,CURLOPT_TIMEOUT,$functimeout+0);
|
||||
curl_setopt($curli,CURLOPT_HTTPHEADER,$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');
|
||||
$gheaders='';
|
||||
$ecode=false;
|
||||
$emsg=false;
|
||||
|
|
Loading…
Reference in a new issue