mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
estrict wp_remote_fopen to remote files.
git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@4827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
817335ed16
commit
81bf2a7ad7
@ -2187,10 +2187,21 @@ function add_magic_quotes($array) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wp_remote_fopen( $uri ) {
|
function wp_remote_fopen( $uri ) {
|
||||||
|
$timeout = 10;
|
||||||
|
$parsed_url = @parse_url($uri);
|
||||||
|
|
||||||
|
if ( !$parsed_url || !is_array($parsed_url) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], array('http','https')) )
|
||||||
|
$uri = 'http://' . $uri;
|
||||||
|
|
||||||
if ( ini_get('allow_url_fopen') ) {
|
if ( ini_get('allow_url_fopen') ) {
|
||||||
$fp = @fopen( $uri, 'r' );
|
$fp = @fopen( $uri, 'r' );
|
||||||
if ( !$fp )
|
if ( !$fp )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//stream_set_timeout($fp, $timeout); // Requires php 4.3
|
||||||
$linea = '';
|
$linea = '';
|
||||||
while( $remote_read = fread($fp, 4096) )
|
while( $remote_read = fread($fp, 4096) )
|
||||||
$linea .= $remote_read;
|
$linea .= $remote_read;
|
||||||
@ -2201,6 +2212,7 @@ function wp_remote_fopen( $uri ) {
|
|||||||
curl_setopt ($handle, CURLOPT_URL, $uri);
|
curl_setopt ($handle, CURLOPT_URL, $uri);
|
||||||
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
|
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
|
||||||
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt ($handle, CURLOPT_TIMEOUT, $timeout);
|
||||||
$buffer = curl_exec($handle);
|
$buffer = curl_exec($handle);
|
||||||
curl_close($handle);
|
curl_close($handle);
|
||||||
return $buffer;
|
return $buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user