Self-hosted Genetify: file_get_contents replaced with CURL function
jamesabruce opened this issue · 0 comments
jamesabruce commented
Due to security restrictions on our server, I was unable to use the file_get_contents() method and had to workaround this by replacing all calls that function with this alternative url_get_contents function, which uses CURL instead but otherwise uses the same syntax.
# url_get_contents function by Andy Langton: http://andylangton.co.uk/
function url_get_contents($url,$useragent='cURL',$headers=false,$follow_redirects=false,$debug=false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($headers==true){
curl_setopt($ch, CURLOPT_HEADER,1);
}
if ($headers=='headers only') {
curl_setopt($ch, CURLOPT_NOBODY ,1);
}
if ($follow_redirects==true) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
if ($debug==true) {
$result['contents']=curl_exec($ch);
$result['info']=curl_getinfo($ch);
}
else $result=curl_exec($ch);
curl_close($ch);
return $result;
}