https://bugzilla.wikimedia.org/show_bug.cgi?id=27391

--- Comment #1 from Amgine <amgine.sae...@gmail.com> 2011-02-14 16:34:45 UTC ---
Here is a function currently used in an extension maintenance script to
retrieve a remote file; it uses cURL which is not universally installed, stores
files in a temporary directory under the extension using a temporary name, the
former of which is fragile and writability must be tested within the script,
and returns the temporary filename or false:

function getHttpFile( $url ){
    $val = false;
    $tempName = tempnam( 'temp/', 'MyExtension' );
    if( is_writable( $tempName ) ){
        $tfh = fopen( $tempName, 'w' );
        if( is_resource( $tfh ) ){
            $ch = curl_init( $url );
            curl_setopt( $ch, CURLOPT_FILE, $tfh );
            curl_setopt( $ch, CURLOPT_HEADER, false );
            if( curl_exec( $ch ) ){
                $val = $tempName;
            }
            curl_close( $ch );
            fclose( $tfh );
        }
    }
    return $val;
}

There are a lot of reasons this is a less-than-desirable solution.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to