Web: new utility function to retrieve contents of an url

The same as file_get_contents() but uses curl to also work if allow_url_fopen is set to false.
This commit is contained in:
Christian Beer 2015-12-09 16:57:03 +01:00
parent 67fa907078
commit 8c49d7cd88
1 changed files with 13 additions and 0 deletions

View File

@ -146,4 +146,17 @@ function is_gpu($plan_class) {
return false;
}
// the same as file_get_contents() but uses curl
//
function url_get_contents($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
?>