From 7d07dc1201fba3336b103a2677bd972afd106a6c Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Fri, 13 May 2005 21:53:18 +0000 Subject: [PATCH] fclose removed, only use curl if we have to - http://mosquito.wordpress.org/view.php?id=1324 - hat tip: rboren git-svn-id: https://develop.svn.wordpress.org/trunk@2606 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 19 +++++++++++-------- xmlrpc.php | 2 -- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1871493385..be0a9a8345 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1859,7 +1859,16 @@ function add_magic_quotes($array) { } function wp_remote_fopen( $uri ) { - if ( function_exists('curl_init') ) { + if ( ini_get('allow_url_fopen') ) { + $fp = fopen( $uri, 'r' ); + if ( !$fp ) + return false; + $linea = ''; + while( $remote_read = fread($fp, 4096) ) + $linea .= $remote_read; + fclose($fp); + return $linea; + } else if ( function_exists('curl_init') ) { $handle = curl_init(); curl_setopt ($handle, CURLOPT_URL, $uri); curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1); @@ -1868,13 +1877,7 @@ function wp_remote_fopen( $uri ) { 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; + return false; } } diff --git a/xmlrpc.php b/xmlrpc.php index d586e538ff..22dae9b656 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -1185,8 +1185,6 @@ class wp_xmlrpc_server extends IXR_Server { $context = str_replace("\n", ' ', $context); $context = str_replace('&', '&', $context); } - - fclose($fp); if (empty($context)) { // URL pattern not found