Make WordPress Core

Changeset 4827


Ignore:
Timestamp:
01/28/2007 10:31:22 PM (18 years ago)
Author:
ryan
Message:

estrict wp_remote_fopen to remote files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.