|
From: Darron F. <da...@fr...> - 2002-03-02 19:42:10
|
> Your call - we could leave the current code in and if curl isn't
available,
> it just uses the regular fopen wrappers to grab the files - that shouldn't
> be too hard.
I just did a quick test and if we do this - we can have our cake and eat it
too:
function getFile($url, $headers=0) {
// If cURL exists - use these.
if (function_exists(curl_init)){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, $headers);
curl_setopt ($ch, CURLOPT_NOBODY, $headers);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.12;
Mac_PowerPC)');
curl_setopt ($ch, CURLOPT_REFERER, '');
$result = curl_exec ($ch);
curl_close ($ch);
} else {
// If cURL doesn't exist, use the fopen wrappers.
}
That way we can use cURL which is:
1. More robust.
2. Faster.
3. Just plain better.
And yet still provide for older installs without cURL.
Thoughts?
|