Make WordPress Core


Ignore:
Timestamp:
09/13/2010 04:36:08 PM (15 years ago)
Author:
scribu
Message:

Update Incutio XML-RPC Library to latest version (1.7.4). Props hakre. Fixes #14703

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-IXR.php

    r14677 r15612  
    11<?php
    22/**
    3  * IXR - The Inutio XML-RPC Library
     3 * IXR - The Incutio XML-RPC Library
     4 *
     5 * Copyright (c) 2010, Incutio Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions are met:
     10 *
     11 *  - Redistributions of source code must retain the above copyright notice,
     12 *    this list of conditions and the following disclaimer.
     13 *  - Redistributions in binary form must reproduce the above copyright
     14 *    notice, this list of conditions and the following disclaimer in the
     15 *    documentation and/or other materials provided with the distribution.
     16 *  - Neither the name of Incutio Ltd. nor the names of its contributors
     17 *    may be used to endorse or promote products derived from this software
     18 *    without specific prior written permission.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
     21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
     30 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    431 *
    532 * @package IXR
    633 * @since 1.5
    734 *
    8  * @copyright Incutio Ltd 2002-2005
    9  * @version 1.7 (beta) 23rd May 2005
    10  * @author Simon Willison
    11  * @link http://scripts.incutio.com/xmlrpc/ Site
    12  * @link http://scripts.incutio.com/xmlrpc/manual.php Manual
    13  * @license BSD License http://www.opensource.org/licenses/bsd-license.php
     35 * @copyright  Incutio Ltd 2010 (http://www.incutio.com)
     36 * @version    1.7.4 7th September 2010
     37 * @author     Simon Willison
     38 * @link       http://scripts.incutio.com/xmlrpc/ Site/manual
     39 * @license    http://www.opensource.org/licenses/bsd-license.php BSD
    1440 */
    1541
     
    2450    var $type;
    2551
    26     function IXR_Value ($data, $type = false) {
     52    function IXR_Value($data, $type = false)
     53    {
    2754        $this->data = $data;
    2855        if (!$type) {
     
    3158        $this->type = $type;
    3259        if ($type == 'struct') {
    33             /* Turn all the values in the array in to new IXR_Value objects */
     60            // Turn all the values in the array in to new IXR_Value objects
    3461            foreach ($this->data as $key => $value) {
    3562                $this->data[$key] = new IXR_Value($value);
     
    4370    }
    4471
    45     function calculateType() {
     72    function calculateType()
     73    {
    4674        if ($this->data === true || $this->data === false) {
    4775            return 'boolean';
     
    5381            return 'double';
    5482        }
     83
    5584        // Deal with IXR object types base64 and date
    5685        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
     
    6089            return 'base64';
    6190        }
     91
    6292        // If it is a normal PHP object convert it in to a struct
    6393        if (is_object($this->data)) {
    64 
    6594            $this->data = get_object_vars($this->data);
    6695            return 'struct';
     
    6998            return 'string';
    7099        }
    71         /* We have an array - is it an array or a struct ? */
     100
     101        // We have an array - is it an array or a struct?
    72102        if ($this->isStruct($this->data)) {
    73103            return 'struct';
     
    77107    }
    78108
    79     function getXml() {
    80         /* Return XML for this value */
     109    function getXml()
     110    {
     111        // Return XML for this value
    81112        switch ($this->type) {
    82113            case 'boolean':
     
    118149    }
    119150
    120     function isStruct($array) {
    121         /* Nasty function to check if an array is a struct or not */
     151    /**
     152     * Checks whether or not the supplied array is a struct or not
     153     *
     154     * @param unknown_type $array
     155     * @return boolean
     156     */
     157    function isStruct($array)
     158    {
    122159        $expected = 0;
    123160        foreach ($array as $key => $value) {
     
    132169
    133170/**
    134  * IXR_Message
     171 * IXR_MESSAGE
    135172 *
    136173 * @package IXR
    137174 * @since 1.5
     175 *
    138176 */
    139 class IXR_Message {
     177class IXR_Message
     178{
    140179    var $message;
    141180    var $messageType;  // methodCall / methodResponse / fault
     
    144183    var $methodName;
    145184    var $params;
     185
    146186    // Current variable stacks
    147187    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
     
    154194    // The XML parser
    155195    var $_parser;
    156     function IXR_Message (&$message) {
    157         $this->message = &$message;
    158     }
    159     function parse() {
    160         // first remove the XML declaration
    161         // this method avoids the RAM usage of preg_replace on very large messages
    162         $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr( $this->message, 0, 100 ), 1 );
    163         $this->message = substr_replace($this->message, $header, 0, 100);
     196
     197    function IXR_Message($message)
     198    {
     199        $this->message =& $message;
     200    }
     201
     202    function parse()
     203    {
     204        // first remove the XML declaration
     205        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
     206        $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1);
     207        $this->message = substr_replace($this->message, $header, 0, 100);
    164208        if (trim($this->message) == '') {
    165209            return false;
    166         }
     210        }
    167211        $this->_parser = xml_parser_create();
    168212        // Set XML parser to take the case of tags in to account
     
    171215        xml_set_object($this->_parser, $this);
    172216        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
    173         xml_set_character_data_handler($this->_parser, 'cdata');
    174         $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
    175         do {
    176             if ( strlen($this->message) <= $chunk_size )
    177                 $final=true;
    178             $part = substr( $this->message, 0, $chunk_size );
    179             $this->message = substr( $this->message, $chunk_size );
    180             if ( !xml_parse( $this->_parser, $part, $final ) )
    181                 return false;
    182             if ( $final )
    183                 break;
    184         } while ( true );
    185         xml_parser_free($this->_parser);
     217        xml_set_character_data_handler($this->_parser, 'cdata');
     218        $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
     219        do {
     220            if (strlen($this->message) <= $chunk_size) {
     221                $final = true;
     222            }
     223            $part = substr($this->message, 0, $chunk_size);
     224            $this->message = substr($this->message, $chunk_size);
     225            if (!xml_parse($this->_parser, $part, $final)) {
     226                return false;
     227            }
     228            if ($final) {
     229                break;
     230            }
     231        } while (true);
     232        xml_parser_free($this->_parser);
     233
    186234        // Grab the error messages, if any
    187235        if ($this->messageType == 'fault') {
    188236            $this->faultCode = $this->params[0]['faultCode'];
    189237            $this->faultString = $this->params[0]['faultString'];
    190         }
     238        }
    191239        return true;
    192240    }
    193     function tag_open($parser, $tag, $attr) {
     241
     242    function tag_open($parser, $tag, $attr)
     243    {
    194244        $this->_currentTagContents = '';
    195245        $this->currentTag = $tag;
     
    200250                $this->messageType = $tag;
    201251                break;
    202             /* Deal with stacks of arrays and structs */
     252                /* Deal with stacks of arrays and structs */
    203253            case 'data':    // data is to all intents and puposes more interesting than array
    204254                $this->_arraystructstypes[] = 'array';
     
    211261        }
    212262    }
    213     function cdata($parser, $cdata) {
     263
     264    function cdata($parser, $cdata)
     265    {
    214266        $this->_currentTagContents .= $cdata;
    215267    }
    216     function tag_close($parser, $tag) {
     268
     269    function tag_close($parser, $tag)
     270    {
    217271        $valueFlag = false;
    218272        switch($tag) {
    219273            case 'int':
    220274            case 'i4':
    221                 $value = (int) trim($this->_currentTagContents);
     275                $value = (int)trim($this->_currentTagContents);
    222276                $valueFlag = true;
    223277                break;
    224278            case 'double':
    225                 $value = (double) trim($this->_currentTagContents);
     279                $value = (double)trim($this->_currentTagContents);
    226280                $valueFlag = true;
    227281                break;
    228282            case 'string':
    229                 $value = $this->_currentTagContents;
     283                $value = (string)trim($this->_currentTagContents);
    230284                $valueFlag = true;
    231285                break;
    232286            case 'dateTime.iso8601':
    233287                $value = new IXR_Date(trim($this->_currentTagContents));
    234                 // $value = $iso->getTimestamp();
    235288                $valueFlag = true;
    236289                break;
     
    243296                break;
    244297            case 'boolean':
    245                 $value = (boolean) trim($this->_currentTagContents);
     298                $value = (boolean)trim($this->_currentTagContents);
    246299                $valueFlag = true;
    247300                break;
    248301            case 'base64':
    249                 $value = base64_decode( trim( $this->_currentTagContents ) );
     302                $value = base64_decode($this->_currentTagContents);
    250303                $valueFlag = true;
    251304                break;
    252             /* Deal with stacks of arrays and structs */
     305                /* Deal with stacks of arrays and structs */
    253306            case 'data':
    254307            case 'struct':
     
    267320                break;
    268321        }
     322
    269323        if ($valueFlag) {
    270324            if (count($this->_arraystructs) > 0) {
     
    292346 * @since 1.5
    293347 */
    294 class IXR_Server {
     348class IXR_Server
     349{
    295350    var $data;
    296351    var $callbacks = array();
    297352    var $message;
    298353    var $capabilities;
    299     function IXR_Server($callbacks = false, $data = false) {
     354
     355    function IXR_Server($callbacks = false, $data = false, $wait = false)
     356    {
    300357        $this->setCapabilities();
    301358        if ($callbacks) {
     
    303360        }
    304361        $this->setCallbacks();
    305         $this->serve($data);
    306     }
    307     function serve($data = false) {
     362        if (!$wait) {
     363            $this->serve($data);
     364        }
     365    }
     366
     367    function serve($data = false)
     368    {
    308369        if (!$data) {
     370            if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
     371                header('Content-Type: text/plain'); // merged from WP #9093
     372                die('XML-RPC server accepts POST requests only.');
     373            }
     374
    309375            global $HTTP_RAW_POST_DATA;
    310             if (!$HTTP_RAW_POST_DATA) {
    311                header( 'Content-Type: text/plain' );
    312                die('XML-RPC server accepts POST requests only.');
    313             }
    314             $data = &$HTTP_RAW_POST_DATA;
     376            if (empty($HTTP_RAW_POST_DATA)) {
     377                // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
     378                $data = file_get_contents('php://input');
     379            } else {
     380                $data =& $HTTP_RAW_POST_DATA;
     381            }
    315382        }
    316383        $this->message = new IXR_Message($data);
     
    322389        }
    323390        $result = $this->call($this->message->methodName, $this->message->params);
     391
    324392        // Is the result an error?
    325393        if (is_a($result, 'IXR_Error')) {
    326394            $this->error($result);
    327395        }
     396
    328397        // Encode the result
    329398        $r = new IXR_Value($result);
    330399        $resultxml = $r->getXml();
     400
    331401        // Create the XML
    332402        $xml = <<<EOD
     
    335405    <param>
    336406      <value>
    337         $resultxml
     407      $resultxml
    338408      </value>
    339409    </param>
     
    342412
    343413EOD;
    344         // Send it
    345         $this->output($xml);
    346     }
    347     function call($methodname, $args) {
     414      // Send it
     415      $this->output($xml);
     416    }
     417
     418    function call($methodname, $args)
     419    {
    348420        if (!$this->hasMethod($methodname)) {
    349             return new IXR_Error(-32601, 'server error. requested method '.
    350                 $methodname.' does not exist.');
     421            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
    351422        }
    352423        $method = $this->callbacks[$methodname];
     424
    353425        // Perform the callback and send the response
    354426        if (count($args) == 1) {
     
    356428            $args = $args[0];
    357429        }
     430
    358431        // Are we dealing with a function or a method?
    359         if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) {
     432        if (is_string($method) && substr($method, 0, 5) == 'this:') {
    360433            // It's a class method - check it exists
    361434            $method = substr($method, 5);
    362435            if (!method_exists($this, $method)) {
    363                 return new IXR_Error(-32601, 'server error. requested class method "'.
    364                     $method.'" does not exist.');
    365             }
    366             // Call the method
     436                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
     437            }
     438
     439            //Call the method
    367440            $result = $this->$method($args);
    368441        } else {
     
    370443            if (is_array($method)) {
    371444                if (!method_exists($method[0], $method[1])) {
    372                     return new IXR_Error(-32601, 'server error. requested object method "'.
    373                         $method[1].'" does not exist.');
     445                    return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
    374446                }
    375447            } else if (!function_exists($method)) {
    376                 return new IXR_Error(-32601, 'server error. requested function "'.
    377                     $method.'" does not exist.');
    378             }
     448                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
     449            }
     450
    379451            // Call the function
    380452            $result = call_user_func($method, $args);
     
    383455    }
    384456
    385     function error($error, $message = false) {
     457    function error($error, $message = false)
     458    {
    386459        // Accepts either an error object or an error code and message
    387460        if ($message && !is_object($error)) {
     
    390463        $this->output($error->getXml());
    391464    }
    392     function output($xml) {
     465
     466    function output($xml)
     467    {
    393468        $xml = '<?xml version="1.0"?>'."\n".$xml;
    394469        $length = strlen($xml);
     
    400475        exit;
    401476    }
    402     function hasMethod($method) {
     477
     478    function hasMethod($method)
     479    {
    403480        return in_array($method, array_keys($this->callbacks));
    404481    }
    405     function setCapabilities() {
     482
     483    function setCapabilities()
     484    {
    406485        // Initialises capabilities array
    407486        $this->capabilities = array(
     
    409488                'specUrl' => 'http://www.xmlrpc.com/spec',
    410489                'specVersion' => 1
    411             ),
     490        ),
    412491            'faults_interop' => array(
    413492                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
    414493                'specVersion' => 20010516
    415             ),
     494        ),
    416495            'system.multicall' => array(
    417496                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
    418497                'specVersion' => 1
    419             ),
     498        ),
    420499        );
    421500    }
    422     function getCapabilities($args) {
     501
     502    function getCapabilities($args)
     503    {
    423504        return $this->capabilities;
    424505    }
    425     function setCallbacks() {
     506
     507    function setCallbacks()
     508    {
    426509        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
    427510        $this->callbacks['system.listMethods'] = 'this:listMethods';
    428511        $this->callbacks['system.multicall'] = 'this:multiCall';
    429512    }
    430     function listMethods($args) {
     513
     514    function listMethods($args)
     515    {
    431516        // Returns a list of methods - uses array_reverse to ensure user defined
    432517        // methods are listed before server defined methods
    433518        return array_reverse(array_keys($this->callbacks));
    434519    }
    435     function multiCall($methodcalls) {
     520
     521    function multiCall($methodcalls)
     522    {
    436523        // See http://www.xmlrpc.com/discuss/msgReader$1208
    437524        $return = array();
     
    463550 * @since 1.5
    464551 */
    465 class IXR_Request {
     552class IXR_Request
     553{
    466554    var $method;
    467555    var $args;
    468556    var $xml;
    469     function IXR_Request($method, $args) {
     557
     558    function IXR_Request($method, $args)
     559    {
    470560        $this->method = $method;
    471561        $this->args = $args;
     
    485575        $this->xml .= '</params></methodCall>';
    486576    }
    487     function getLength() {
     577
     578    function getLength()
     579    {
    488580        return strlen($this->xml);
    489581    }
    490     function getXml() {
     582
     583    function getXml()
     584    {
    491585        return $this->xml;
    492586    }
     
    498592 * @package IXR
    499593 * @since 1.5
     594 *
    500595 */
    501 class IXR_Client {
     596class IXR_Client
     597{
    502598    var $server;
    503599    var $port;
    504600    var $path;
    505601    var $useragent;
    506     var $headers;
    507602    var $response;
    508603    var $message = false;
    509604    var $debug = false;
    510605    var $timeout;
     606
    511607    // Storage place for an error message
    512608    var $error = false;
    513     function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
     609
     610    function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
     611    {
    514612        if (!$path) {
    515613            // Assume we have been given a URL instead
     
    518616            $this->port = isset($bits['port']) ? $bits['port'] : 80;
    519617            $this->path = isset($bits['path']) ? $bits['path'] : '/';
     618
    520619            // Make absolutely sure we have a path
    521620            if (!$this->path) {
     
    530629        $this->timeout = $timeout;
    531630    }
    532     function query() {
     631
     632    function query()
     633    {
    533634        $args = func_get_args();
    534635        $method = array_shift($args);
     
    539640        $request  = "POST {$this->path} HTTP/1.0$r";
    540641
    541         $this->headers['Host']          = $this->server;
    542         $this->headers['Content-Type']  = 'text/xml';
    543         $this->headers['User-Agent']    = $this->useragent;
    544         $this->headers['Content-Length']= $length;
    545 
    546         foreach( $this->headers as $header => $value ) {
    547             $request .= "{$header}: {$value}{$r}";
    548         }
    549         $request .= $r;
     642        // Merged from WP #8145 - allow custom headers
     643        $this->headers['Host']          = $this->server;
     644        $this->headers['Content-Type']  = 'text/xml';
     645        $this->headers['User-Agent']    = $this->useragent;
     646        $this->headers['Content-Length']= $length;
     647
     648        foreach( $this->headers as $header => $value ) {
     649            $request .= "{$header}: {$value}{$r}";
     650        }
     651        $request .= $r;
    550652
    551653        $request .= $xml;
     654
    552655        // Now send the request
    553656        if ($this->debug) {
    554657            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
    555658        }
     659
    556660        if ($this->timeout) {
    557661            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
     
    560664        }
    561665        if (!$fp) {
    562             $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
     666            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
    563667            return false;
    564668        }
    565669        fputs($fp, $request);
    566670        $contents = '';
    567         $debug_contents = '';
     671        $debugContents = '';
    568672        $gotFirstLine = false;
    569673        $gettingHeaders = true;
     
    573677                // Check line for '200'
    574678                if (strstr($line, '200') === false) {
    575                     $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
     679                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
    576680                    return false;
    577681                }
     
    582686            }
    583687            if (!$gettingHeaders) {
    584                 // WP#12559 remove trim so as to not strip newlines from received response.
     688                // merged from WP #12559 - remove trim
    585689                $contents .= $line;
    586690            }
    587691            if ($this->debug) {
    588                 $debug_contents .= $line;
     692                $debugContents .= $line;
    589693            }
    590694        }
    591695        if ($this->debug) {
    592             echo '<pre class="ixr_response">'.htmlspecialchars($debug_contents)."\n</pre>\n\n";
    593         }
     696            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
     697        }
     698
    594699        // Now parse what we've got back
    595700        $this->message = new IXR_Message($contents);
     
    599704            return false;
    600705        }
     706
    601707        // Is the message a fault?
    602708        if ($this->message->messageType == 'fault') {
     
    604710            return false;
    605711        }
     712
    606713        // Message must be OK
    607714        return true;
    608715    }
    609     function getResponse() {
     716
     717    function getResponse()
     718    {
    610719        // methodResponses can only have one param - return that
    611720        return $this->message->params[0];
    612721    }
    613     function isError() {
     722
     723    function isError()
     724    {
    614725        return (is_object($this->error));
    615726    }
    616     function getErrorCode() {
     727
     728    function getErrorCode()
     729    {
    617730        return $this->error->code;
    618731    }
    619     function getErrorMessage() {
     732
     733    function getErrorMessage()
     734    {
    620735        return $this->error->message;
    621736    }
    622737}
     738
    623739
    624740/**
     
    628744 * @since 1.5
    629745 */
    630 class IXR_Error {
     746class IXR_Error
     747{
    631748    var $code;
    632749    var $message;
    633     function IXR_Error($code, $message) {
     750
     751    function IXR_Error($code, $message)
     752    {
    634753        $this->code = $code;
    635         // WP adds htmlspecialchars(). See #5666
    636754        $this->message = htmlspecialchars($message);
    637755    }
    638     function getXml() {
     756
     757    function getXml()
     758    {
    639759        $xml = <<<EOD
    640760<methodResponse>
     
    674794    var $second;
    675795    var $timezone;
    676     function IXR_Date($time) {
     796
     797    function IXR_Date($time)
     798    {
    677799        // $time can be a PHP timestamp or an ISO one
    678800        if (is_numeric($time)) {
     
    682804        }
    683805    }
    684     function parseTimestamp($timestamp) {
     806
     807    function parseTimestamp($timestamp)
     808    {
    685809        $this->year = date('Y', $timestamp);
    686810        $this->month = date('m', $timestamp);
     
    689813        $this->minute = date('i', $timestamp);
    690814        $this->second = date('s', $timestamp);
    691         // WP adds timezone. See #2036
    692815        $this->timezone = '';
    693816    }
    694     function parseIso($iso) {
     817
     818    function parseIso($iso)
     819    {
    695820        $this->year = substr($iso, 0, 4);
    696821        $this->month = substr($iso, 4, 2);
     
    699824        $this->minute = substr($iso, 12, 2);
    700825        $this->second = substr($iso, 15, 2);
    701         // WP adds timezone. See #2036
    702826        $this->timezone = substr($iso, 17);
    703827    }
    704     function getIso() {
    705         // WP adds timezone. See #2036
     828
     829    function getIso()
     830    {
    706831        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
    707832    }
    708     function getXml() {
     833
     834    function getXml()
     835    {
    709836        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
    710837    }
    711     function getTimestamp() {
     838
     839    function getTimestamp()
     840    {
    712841        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
    713842    }
     
    720849 * @since 1.5
    721850 */
    722 class IXR_Base64 {
     851class IXR_Base64
     852{
    723853    var $data;
    724     function IXR_Base64($data) {
     854
     855    function IXR_Base64($data)
     856    {
    725857        $this->data = $data;
    726858    }
    727     function getXml() {
     859
     860    function getXml()
     861    {
    728862        return '<base64>'.base64_encode($this->data).'</base64>';
    729863    }
     
    736870 * @since 1.5
    737871 */
    738 class IXR_IntrospectionServer extends IXR_Server {
     872class IXR_IntrospectionServer extends IXR_Server
     873{
    739874    var $signatures;
    740875    var $help;
    741     function IXR_IntrospectionServer() {
     876
     877    function IXR_IntrospectionServer()
     878    {
    742879        $this->setCallbacks();
    743880        $this->setCapabilities();
     
    771908        );
    772909    }
    773     function addCallback($method, $callback, $args, $help) {
     910
     911    function addCallback($method, $callback, $args, $help)
     912    {
    774913        $this->callbacks[$method] = $callback;
    775914        $this->signatures[$method] = $args;
    776915        $this->help[$method] = $help;
    777916    }
    778     function call($methodname, $args) {
     917
     918    function call($methodname, $args)
     919    {
    779920        // Make sure it's in an array
    780921        if ($args && !is_array($args)) {
    781922            $args = array($args);
    782923        }
     924
    783925        // Over-rides default call method, adds signature check
    784926        if (!$this->hasMethod($methodname)) {
     
    788930        $signature = $this->signatures[$methodname];
    789931        $returnType = array_shift($signature);
     932
    790933        // Check the number of arguments
    791934        if (count($args) != count($signature)) {
    792935            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
    793936        }
     937
    794938        // Check the argument types
    795939        $ok = true;
     
    836980        return parent::call($methodname, $argsbackup);
    837981    }
    838     function methodSignature($method) {
     982
     983    function methodSignature($method)
     984    {
    839985        if (!$this->hasMethod($method)) {
    840986            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
     
    8741020        return $return;
    8751021    }
    876     function methodHelp($method) {
     1022
     1023    function methodHelp($method)
     1024    {
    8771025        return $this->help[$method];
    8781026    }
     
    8851033 * @since 1.5
    8861034 */
    887 class IXR_ClientMulticall extends IXR_Client {
     1035class IXR_ClientMulticall extends IXR_Client
     1036{
    8881037    var $calls = array();
    889     function IXR_ClientMulticall($server, $path = false, $port = 80) {
     1038
     1039    function IXR_ClientMulticall($server, $path = false, $port = 80)
     1040    {
    8901041        parent::IXR_Client($server, $path, $port);
    8911042        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
    8921043    }
    893     function addCall() {
     1044
     1045    function addCall()
     1046    {
    8941047        $args = func_get_args();
    8951048        $methodName = array_shift($args);
     
    9001053        $this->calls[] = $struct;
    9011054    }
    902     function query() {
     1055
     1056    function query()
     1057    {
    9031058        // Prepare multicall, then call the parent::query() method
    9041059        return parent::query('system.multicall', $this->calls);
Note: See TracChangeset for help on using the changeset viewer.