Make WordPress Core

Ticket #1324: wp_remote_fopen.txt

File wp_remote_fopen.txt, 557 bytes (added by macmanx, 21 years ago)
Line 
1function wp_remote_fopen( $uri ) {
2        if ( ini_get('allow_url_fopen') ) {
3                $fp = fopen( $uri, 'r' );
4                if ( !$fp )
5                        return false;
6                $linea = '';
7                while( $remote_read = fread($fp, 4096) )
8                        $linea .= $remote_read;
9                return $linea;
10        } else if ( function_exists('curl_init') ) {
11                $handle = curl_init();
12                curl_setopt ($handle, CURLOPT_URL, $uri);
13                curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
14                curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
15                $buffer = curl_exec($handle);
16                curl_close($handle);
17                return $buffer;
18        } else {
19                return false;
20        }       
21}