Changeset 4827

Show
Ignore:
Timestamp:
01/28/07 22:31:22 (2 years ago)
Author:
ryan
Message:

estrict wp_remote_fopen to remote files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.0/wp-includes/functions.php

    r4777 r4827  
    21882188 
    21892189function wp_remote_fopen( $uri ) { 
     2190    $timeout = 10; 
     2191    $parsed_url = @parse_url($uri); 
     2192 
     2193    if ( !$parsed_url || !is_array($parsed_url) ) 
     2194        return false; 
     2195 
     2196    if ( !isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], array('http','https')) ) 
     2197        $uri = 'http://' . $uri; 
     2198 
    21902199    if ( ini_get('allow_url_fopen') ) { 
    21912200        $fp = @fopen( $uri, 'r' ); 
    21922201        if ( !$fp ) 
    21932202            return false; 
     2203 
     2204        //stream_set_timeout($fp, $timeout); // Requires php 4.3 
    21942205        $linea = ''; 
    21952206        while( $remote_read = fread($fp, 4096) ) 
     
    22022213        curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1); 
    22032214        curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1); 
     2215        curl_setopt ($handle, CURLOPT_TIMEOUT, $timeout); 
    22042216        $buffer = curl_exec($handle); 
    22052217        curl_close($handle);