Use CURL if available, possible fix for http://mosquito.wordpress.org/view.php?id=1166

git-svn-id: https://develop.svn.wordpress.org/trunk@2581 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2005-05-03 07:52:11 +00:00
parent 423287de0d
commit 9648173c70
3 changed files with 26 additions and 11 deletions
+21 -1
View File
@@ -1858,4 +1858,24 @@ function add_magic_quotes($array) {
return $array;
}
?>
function wp_remote_fopen( $uri ) {
if ( function_exists('curl_init') ) {
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL, $uri);
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($handle);
curl_close($handle);
return $buffer;
} else {
$fp = fopen( $uri, 'r' );
if ( !$fp )
return false;
$linea = '';
while( $remote_read = fread($fp, 4096) )
$linea .= $remote_read;
return $linea;
}
}
?>