Make WordPress Core


Ignore:
Timestamp:
01/16/2007 06:41:05 PM (20 years ago)
Author:
ryan
Message:

Restrict wp_remote_fopen to remote files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r4725 r4752  
    775775
    776776function wp_remote_fopen( $uri ) {
     777        $timeout = 10;
     778        $parsed_url = @parse_url($uri);
     779
     780        if ( !$parsed_url || !is_array($parsed_url) )
     781                return false;
     782
     783        if ( !isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], array('http','https')) )
     784                $uri = 'http://' . $uri;
     785
    777786        if ( ini_get('allow_url_fopen') ) {
    778787                $fp = @fopen( $uri, 'r' );
    779788                if ( !$fp )
    780789                        return false;
     790
     791                //stream_set_timeout($fp, $timeout); // Requires php 4.3
    781792                $linea = '';
    782793                while( $remote_read = fread($fp, 4096) )
    … …  
    789800                curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
    790801                curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
     802                curl_setopt ($handle, CURLOPT_TIMEOUT, $timeout);
    791803                $buffer = curl_exec($handle);
    792804                curl_close($handle);
Note: See TracChangeset for help on using the changeset viewer.