Welcome Guest, Not a member yet? Register   Sign In
SOLVED: xmlrpc blues
#1

[eluser]alexsancho[/eluser]
Hi, I'm finishing an Image gallery based on CI, it's just a port of MT Photo Gallery Templates, but i need some help to finish it.

I've added an XMLRPC interface based on metaweblog, to allow desktop publishing, that works really well except for file transfers.

This is the relevant part of code that writes the file locally, nothing special as you can see, but every image i try to transfer is corrupted.

Code:
$data = $parameters['3'];
        $name = preg_replace("/\s+/", "_", $data['name']);
    $type = $data['type'];
    $bits = $data['bits'];
        
        log_message('debug','(MW) Received '.strlen($bits).' bytes');
    
        $localpath = './thumbs/'.$name;
        if(!is_dir(dirname($localpath))) {
            @mkdir(dirname($localpath));
        } else if(file_exists($localpath)) {
            @unlink($localpath);
        }

        /* encode & write data (binary) */
    $ifp = fopen($localpath, 'wb');
    $success = fwrite($ifp, $bits, strlen($bits));
    fclose($ifp);

    @chmod($localpath, 0777);

Not really sure if this is a CI issue, but i like to know if anyone has a similar function working.

thanks in advance

UPDATE: Seems that i've catched the problem. CI doesn't decode properly binary data. If i remove 'base64_decode' from xmlrpc library and decode the variable later, inside controller, all works fine.

Maybe anyone can check this to confirm if there's a bug in xmlrpc library.

There's another problem with xmrpcs library, with PHP 5 i need to modify the "parseRequest" method in this way to make it work:

Code:
function parseRequest($data='')
    {
        global $HTTP_RAW_POST_DATA;
        
        //-------------------------------------
        //  Get Data
        //-------------------------------------

        if ($data == '')
        {
            if ( !isset( $HTTP_RAW_POST_DATA ) ) {
                   $HTTP_RAW_POST_DATA = file_get_contents("php://input");
            }
            $data = $HTTP_RAW_POST_DATA;
        }
    ...
    }

Hopes this will be fixed in future releases




Theme © iAndrew 2016 - Forum software by © MyBB