Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r16809 r14677  
    11<?php
    22/**
    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.
    31  *
    32  * @package IXR
    33  * @since 1.5
    34  *
    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
     3 * IXR - The Inutio XML-RPC Library
     4 *
     5 * @package IXR
     6 * @since 1.5
     7 *
     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
    4014 */
    4115
     
    5024    var $type;
    5125
    52     function IXR_Value($data, $type = false)
    53     {
     26    function IXR_Value ($data, $type = false) {
    5427        $this->data = $data;
    5528        if (!$type) {
     
    5831        $this->type = $type;
    5932        if ($type == 'struct') {
    60             // Turn all the values in the array in to new IXR_Value objects
     33            /* Turn all the values in the array in to new IXR_Value objects */
    6134            foreach ($this->data as $key => $value) {
    6235                $this->data[$key] = new IXR_Value($value);
     
    7043    }
    7144
    72     function calculateType()
    73     {
     45    function calculateType() {
    7446        if ($this->data === true || $this->data === false) {
    7547            return 'boolean';
     
    8153            return 'double';
    8254        }
    83 
    8455        // Deal with IXR object types base64 and date
    8556        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
     
    8960            return 'base64';
    9061        }
    91 
    9262        // If it is a normal PHP object convert it in to a struct
    9363        if (is_object($this->data)) {
     64
    9465            $this->data = get_object_vars($this->data);
    9566            return 'struct';
     
    9869            return 'string';
    9970        }
    100 
    101         // We have an array - is it an array or a struct?
     71        /* We have an array - is it an array or a struct ? */
    10272        if ($this->isStruct($this->data)) {
    10373            return 'struct';
     
    10777    }
    10878
    109     function getXml()
    110     {
    111         // Return XML for this value
     79    function getXml() {
     80        /* Return XML for this value */
    11281        switch ($this->type) {
    11382            case 'boolean':
     
    149118    }
    150119
    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     {
     120    function isStruct($array) {
     121        /* Nasty function to check if an array is a struct or not */
    159122        $expected = 0;
    160123        foreach ($array as $key => $value) {
     
    169132
    170133/**
    171  * IXR_MESSAGE
    172  *
    173  * @package IXR
    174  * @since 1.5
    175  *
    176  */
    177 class IXR_Message
    178 {
     134 * IXR_Message
     135 *
     136 * @package IXR
     137 * @since 1.5
     138 */
     139class IXR_Message {
    179140    var $message;
    180141    var $messageType;  // methodCall / methodResponse / fault
     
    183144    var $methodName;
    184145    var $params;
    185 
    186146    // Current variable stacks
    187147    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
     
    194154    // The XML parser
    195155    var $_parser;
    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);
     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);
    208164        if (trim($this->message) == '') {
    209165            return false;
    210         }
     166        }
    211167        $this->_parser = xml_parser_create();
    212168        // Set XML parser to take the case of tags in to account
     
    215171        xml_set_object($this->_parser, $this);
    216172        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
    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         $final = false;
    220         do {
    221             if (strlen($this->message) <= $chunk_size) {
    222                 $final = true;
    223             }
    224             $part = substr($this->message, 0, $chunk_size);
    225             $this->message = substr($this->message, $chunk_size);
    226             if (!xml_parse($this->_parser, $part, $final)) {
    227                 return false;
    228             }
    229             if ($final) {
    230                 break;
    231             }
    232         } while (true);
    233         xml_parser_free($this->_parser);
    234 
     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);
    235186        // Grab the error messages, if any
    236187        if ($this->messageType == 'fault') {
    237188            $this->faultCode = $this->params[0]['faultCode'];
    238189            $this->faultString = $this->params[0]['faultString'];
    239         }
     190        }
    240191        return true;
    241192    }
    242 
    243     function tag_open($parser, $tag, $attr)
    244     {
     193    function tag_open($parser, $tag, $attr) {
    245194        $this->_currentTagContents = '';
    246195        $this->currentTag = $tag;
     
    251200                $this->messageType = $tag;
    252201                break;
    253                 /* Deal with stacks of arrays and structs */
     202            /* Deal with stacks of arrays and structs */
    254203            case 'data':    // data is to all intents and puposes more interesting than array
    255204                $this->_arraystructstypes[] = 'array';
     
    262211        }
    263212    }
    264 
    265     function cdata($parser, $cdata)
    266     {
     213    function cdata($parser, $cdata) {
    267214        $this->_currentTagContents .= $cdata;
    268215    }
    269 
    270     function tag_close($parser, $tag)
    271     {
     216    function tag_close($parser, $tag) {
    272217        $valueFlag = false;
    273218        switch($tag) {
    274219            case 'int':
    275220            case 'i4':
    276                 $value = (int)trim($this->_currentTagContents);
     221                $value = (int) trim($this->_currentTagContents);
    277222                $valueFlag = true;
    278223                break;
    279224            case 'double':
    280                 $value = (double)trim($this->_currentTagContents);
     225                $value = (double) trim($this->_currentTagContents);
    281226                $valueFlag = true;
    282227                break;
    283228            case 'string':
    284                 $value = (string)trim($this->_currentTagContents);
     229                $value = $this->_currentTagContents;
    285230                $valueFlag = true;
    286231                break;
    287232            case 'dateTime.iso8601':
    288233                $value = new IXR_Date(trim($this->_currentTagContents));
     234                // $value = $iso->getTimestamp();
    289235                $valueFlag = true;
    290236                break;
     
    297243                break;
    298244            case 'boolean':
    299                 $value = (boolean)trim($this->_currentTagContents);
     245                $value = (boolean) trim($this->_currentTagContents);
    300246                $valueFlag = true;
    301247                break;
    302248            case 'base64':
    303                 $value = base64_decode($this->_currentTagContents);
     249                $value = base64_decode( trim( $this->_currentTagContents ) );
    304250                $valueFlag = true;
    305251                break;
    306                 /* Deal with stacks of arrays and structs */
     252            /* Deal with stacks of arrays and structs */
    307253            case 'data':
    308254            case 'struct':
     
    321267                break;
    322268        }
    323 
    324269        if ($valueFlag) {
    325270            if (count($this->_arraystructs) > 0) {
     
    347292 * @since 1.5
    348293 */
    349 class IXR_Server
    350 {
     294class IXR_Server {
    351295    var $data;
    352296    var $callbacks = array();
    353297    var $message;
    354298    var $capabilities;
    355 
    356     function IXR_Server($callbacks = false, $data = false, $wait = false)
    357     {
     299    function IXR_Server($callbacks = false, $data = false) {
    358300        $this->setCapabilities();
    359301        if ($callbacks) {
     
    361303        }
    362304        $this->setCallbacks();
    363         if (!$wait) {
    364             $this->serve($data);
    365         }
    366     }
    367 
    368     function serve($data = false)
    369     {
     305        $this->serve($data);
     306    }
     307    function serve($data = false) {
    370308        if (!$data) {
    371             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
    372                 header('Content-Type: text/plain'); // merged from WP #9093
    373                 die('XML-RPC server accepts POST requests only.');
    374             }
    375 
    376309            global $HTTP_RAW_POST_DATA;
    377             if (empty($HTTP_RAW_POST_DATA)) {
    378                 // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
    379                 $data = file_get_contents('php://input');
    380             } else {
    381                 $data =& $HTTP_RAW_POST_DATA;
    382             }
     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;
    383315        }
    384316        $this->message = new IXR_Message($data);
     
    390322        }
    391323        $result = $this->call($this->message->methodName, $this->message->params);
    392 
    393324        // Is the result an error?
    394325        if (is_a($result, 'IXR_Error')) {
    395326            $this->error($result);
    396327        }
    397 
    398328        // Encode the result
    399329        $r = new IXR_Value($result);
    400330        $resultxml = $r->getXml();
    401 
    402331        // Create the XML
    403332        $xml = <<<EOD
     
    406335    <param>
    407336      <value>
    408       $resultxml
     337        $resultxml
    409338      </value>
    410339    </param>
     
    413342
    414343EOD;
    415       // Send it
    416       $this->output($xml);
    417     }
    418 
    419     function call($methodname, $args)
    420     {
     344        // Send it
     345        $this->output($xml);
     346    }
     347    function call($methodname, $args) {
    421348        if (!$this->hasMethod($methodname)) {
    422             return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
     349            return new IXR_Error(-32601, 'server error. requested method '.
     350                $methodname.' does not exist.');
    423351        }
    424352        $method = $this->callbacks[$methodname];
    425 
    426353        // Perform the callback and send the response
    427354        if (count($args) == 1) {
     
    429356            $args = $args[0];
    430357        }
    431 
    432358        // Are we dealing with a function or a method?
    433         if (is_string($method) && substr($method, 0, 5) == 'this:') {
     359        if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) {
    434360            // It's a class method - check it exists
    435361            $method = substr($method, 5);
    436362            if (!method_exists($this, $method)) {
    437                 return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
    438             }
    439 
    440             //Call the method
     363                return new IXR_Error(-32601, 'server error. requested class method "'.
     364                    $method.'" does not exist.');
     365            }
     366            // Call the method
    441367            $result = $this->$method($args);
    442368        } else {
    443369            // It's a function - does it exist?
    444370            if (is_array($method)) {
    445                 if (!is_callable(array($method[0], $method[1]))) {
    446                     return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
     371                if (!method_exists($method[0], $method[1])) {
     372                    return new IXR_Error(-32601, 'server error. requested object method "'.
     373                        $method[1].'" does not exist.');
    447374                }
    448375            } else if (!function_exists($method)) {
    449                 return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
    450             }
    451 
     376                return new IXR_Error(-32601, 'server error. requested function "'.
     377                    $method.'" does not exist.');
     378            }
    452379            // Call the function
    453380            $result = call_user_func($method, $args);
     
    456383    }
    457384
    458     function error($error, $message = false)
    459     {
     385    function error($error, $message = false) {
    460386        // Accepts either an error object or an error code and message
    461387        if ($message && !is_object($error)) {
     
    464390        $this->output($error->getXml());
    465391    }
    466 
    467     function output($xml)
    468     {
     392    function output($xml) {
    469393        $xml = '<?xml version="1.0"?>'."\n".$xml;
    470394        $length = strlen($xml);
     
    476400        exit;
    477401    }
    478 
    479     function hasMethod($method)
    480     {
     402    function hasMethod($method) {
    481403        return in_array($method, array_keys($this->callbacks));
    482404    }
    483 
    484     function setCapabilities()
    485     {
     405    function setCapabilities() {
    486406        // Initialises capabilities array
    487407        $this->capabilities = array(
     
    489409                'specUrl' => 'http://www.xmlrpc.com/spec',
    490410                'specVersion' => 1
    491         ),
     411            ),
    492412            'faults_interop' => array(
    493413                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
    494414                'specVersion' => 20010516
    495         ),
     415            ),
    496416            'system.multicall' => array(
    497417                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
    498418                'specVersion' => 1
    499         ),
     419            ),
    500420        );
    501421    }
    502 
    503     function getCapabilities($args)
    504     {
     422    function getCapabilities($args) {
    505423        return $this->capabilities;
    506424    }
    507 
    508     function setCallbacks()
    509     {
     425    function setCallbacks() {
    510426        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
    511427        $this->callbacks['system.listMethods'] = 'this:listMethods';
    512428        $this->callbacks['system.multicall'] = 'this:multiCall';
    513429    }
    514 
    515     function listMethods($args)
    516     {
     430    function listMethods($args) {
    517431        // Returns a list of methods - uses array_reverse to ensure user defined
    518432        // methods are listed before server defined methods
    519433        return array_reverse(array_keys($this->callbacks));
    520434    }
    521 
    522     function multiCall($methodcalls)
    523     {
     435    function multiCall($methodcalls) {
    524436        // See http://www.xmlrpc.com/discuss/msgReader$1208
    525437        $return = array();
     
    551463 * @since 1.5
    552464 */
    553 class IXR_Request
    554 {
     465class IXR_Request {
    555466    var $method;
    556467    var $args;
    557468    var $xml;
    558 
    559     function IXR_Request($method, $args)
    560     {
     469    function IXR_Request($method, $args) {
    561470        $this->method = $method;
    562471        $this->args = $args;
     
    576485        $this->xml .= '</params></methodCall>';
    577486    }
    578 
    579     function getLength()
    580     {
     487    function getLength() {
    581488        return strlen($this->xml);
    582489    }
    583 
    584     function getXml()
    585     {
     490    function getXml() {
    586491        return $this->xml;
    587492    }
     
    593498 * @package IXR
    594499 * @since 1.5
    595  *
    596  */
    597 class IXR_Client
    598 {
     500 */
     501class IXR_Client {
    599502    var $server;
    600503    var $port;
    601504    var $path;
    602505    var $useragent;
     506    var $headers;
    603507    var $response;
    604508    var $message = false;
    605509    var $debug = false;
    606510    var $timeout;
    607     var $headers = array();
    608 
    609511    // Storage place for an error message
    610512    var $error = false;
    611 
    612     function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
    613     {
     513    function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
    614514        if (!$path) {
    615515            // Assume we have been given a URL instead
     
    618518            $this->port = isset($bits['port']) ? $bits['port'] : 80;
    619519            $this->path = isset($bits['path']) ? $bits['path'] : '/';
    620 
    621520            // Make absolutely sure we have a path
    622521            if (!$this->path) {
     
    631530        $this->timeout = $timeout;
    632531    }
    633 
    634     function query()
    635     {
     532    function query() {
    636533        $args = func_get_args();
    637534        $method = array_shift($args);
     
    642539        $request  = "POST {$this->path} HTTP/1.0$r";
    643540
    644         // Merged from WP #8145 - allow custom headers
    645         $this->headers['Host']          = $this->server;
    646         $this->headers['Content-Type']  = 'text/xml';
    647         $this->headers['User-Agent']    = $this->useragent;
    648         $this->headers['Content-Length']= $length;
    649 
    650         foreach( $this->headers as $header => $value ) {
    651             $request .= "{$header}: {$value}{$r}";
    652         }
    653         $request .= $r;
     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;
    654550
    655551        $request .= $xml;
    656 
    657552        // Now send the request
    658553        if ($this->debug) {
    659554            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
    660555        }
    661 
    662556        if ($this->timeout) {
    663557            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
     
    666560        }
    667561        if (!$fp) {
    668             $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
     562            $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
    669563            return false;
    670564        }
    671565        fputs($fp, $request);
    672566        $contents = '';
    673         $debugContents = '';
     567        $debug_contents = '';
    674568        $gotFirstLine = false;
    675569        $gettingHeaders = true;
     
    679573                // Check line for '200'
    680574                if (strstr($line, '200') === false) {
    681                     $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
     575                    $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
    682576                    return false;
    683577                }
     
    688582            }
    689583            if (!$gettingHeaders) {
    690                 // merged from WP #12559 - remove trim
     584                // WP#12559 remove trim so as to not strip newlines from received response.
    691585                $contents .= $line;
    692586            }
    693587            if ($this->debug) {
    694                 $debugContents .= $line;
     588                $debug_contents .= $line;
    695589            }
    696590        }
    697591        if ($this->debug) {
    698             echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
    699         }
    700 
     592            echo '<pre class="ixr_response">'.htmlspecialchars($debug_contents)."\n</pre>\n\n";
     593        }
    701594        // Now parse what we've got back
    702595        $this->message = new IXR_Message($contents);
     
    706599            return false;
    707600        }
    708 
    709601        // Is the message a fault?
    710602        if ($this->message->messageType == 'fault') {
     
    712604            return false;
    713605        }
    714 
    715606        // Message must be OK
    716607        return true;
    717608    }
    718 
    719     function getResponse()
    720     {
     609    function getResponse() {
    721610        // methodResponses can only have one param - return that
    722611        return $this->message->params[0];
    723612    }
    724 
    725     function isError()
    726     {
     613    function isError() {
    727614        return (is_object($this->error));
    728615    }
    729 
    730     function getErrorCode()
    731     {
     616    function getErrorCode() {
    732617        return $this->error->code;
    733618    }
    734 
    735     function getErrorMessage()
    736     {
     619    function getErrorMessage() {
    737620        return $this->error->message;
    738621    }
    739622}
    740623
    741 
    742624/**
    743625 * IXR_Error
     
    746628 * @since 1.5
    747629 */
    748 class IXR_Error
    749 {
     630class IXR_Error {
    750631    var $code;
    751632    var $message;
    752 
    753     function IXR_Error($code, $message)
    754     {
     633    function IXR_Error($code, $message) {
    755634        $this->code = $code;
     635        // WP adds htmlspecialchars(). See #5666
    756636        $this->message = htmlspecialchars($message);
    757637    }
    758 
    759     function getXml()
    760     {
     638    function getXml() {
    761639        $xml = <<<EOD
    762640<methodResponse>
     
    796674    var $second;
    797675    var $timezone;
    798 
    799     function IXR_Date($time)
    800     {
     676    function IXR_Date($time) {
    801677        // $time can be a PHP timestamp or an ISO one
    802678        if (is_numeric($time)) {
     
    806682        }
    807683    }
    808 
    809     function parseTimestamp($timestamp)
    810     {
     684    function parseTimestamp($timestamp) {
    811685        $this->year = date('Y', $timestamp);
    812686        $this->month = date('m', $timestamp);
     
    815689        $this->minute = date('i', $timestamp);
    816690        $this->second = date('s', $timestamp);
     691        // WP adds timezone. See #2036
    817692        $this->timezone = '';
    818693    }
    819 
    820     function parseIso($iso)
    821     {
     694    function parseIso($iso) {
    822695        $this->year = substr($iso, 0, 4);
    823696        $this->month = substr($iso, 4, 2);
     
    826699        $this->minute = substr($iso, 12, 2);
    827700        $this->second = substr($iso, 15, 2);
     701        // WP adds timezone. See #2036
    828702        $this->timezone = substr($iso, 17);
    829703    }
    830 
    831     function getIso()
    832     {
     704    function getIso() {
     705        // WP adds timezone. See #2036
    833706        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
    834707    }
    835 
    836     function getXml()
    837     {
     708    function getXml() {
    838709        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
    839710    }
    840 
    841     function getTimestamp()
    842     {
     711    function getTimestamp() {
    843712        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
    844713    }
     
    851720 * @since 1.5
    852721 */
    853 class IXR_Base64
    854 {
     722class IXR_Base64 {
    855723    var $data;
    856 
    857     function IXR_Base64($data)
    858     {
     724    function IXR_Base64($data) {
    859725        $this->data = $data;
    860726    }
    861 
    862     function getXml()
    863     {
     727    function getXml() {
    864728        return '<base64>'.base64_encode($this->data).'</base64>';
    865729    }
     
    872736 * @since 1.5
    873737 */
    874 class IXR_IntrospectionServer extends IXR_Server
    875 {
     738class IXR_IntrospectionServer extends IXR_Server {
    876739    var $signatures;
    877740    var $help;
    878 
    879     function IXR_IntrospectionServer()
    880     {
     741    function IXR_IntrospectionServer() {
    881742        $this->setCallbacks();
    882743        $this->setCapabilities();
     
    910771        );
    911772    }
    912 
    913     function addCallback($method, $callback, $args, $help)
    914     {
     773    function addCallback($method, $callback, $args, $help) {
    915774        $this->callbacks[$method] = $callback;
    916775        $this->signatures[$method] = $args;
    917776        $this->help[$method] = $help;
    918777    }
    919 
    920     function call($methodname, $args)
    921     {
     778    function call($methodname, $args) {
    922779        // Make sure it's in an array
    923780        if ($args && !is_array($args)) {
    924781            $args = array($args);
    925782        }
    926 
    927783        // Over-rides default call method, adds signature check
    928784        if (!$this->hasMethod($methodname)) {
     
    932788        $signature = $this->signatures[$methodname];
    933789        $returnType = array_shift($signature);
    934 
    935790        // Check the number of arguments
    936791        if (count($args) != count($signature)) {
    937792            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
    938793        }
    939 
    940794        // Check the argument types
    941795        $ok = true;
     
    982836        return parent::call($methodname, $argsbackup);
    983837    }
    984 
    985     function methodSignature($method)
    986     {
     838    function methodSignature($method) {
    987839        if (!$this->hasMethod($method)) {
    988840            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
     
    1022874        return $return;
    1023875    }
    1024 
    1025     function methodHelp($method)
    1026     {
     876    function methodHelp($method) {
    1027877        return $this->help[$method];
    1028878    }
     
    1035885 * @since 1.5
    1036886 */
    1037 class IXR_ClientMulticall extends IXR_Client
    1038 {
     887class IXR_ClientMulticall extends IXR_Client {
    1039888    var $calls = array();
    1040 
    1041     function IXR_ClientMulticall($server, $path = false, $port = 80)
    1042     {
     889    function IXR_ClientMulticall($server, $path = false, $port = 80) {
    1043890        parent::IXR_Client($server, $path, $port);
    1044891        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
    1045892    }
    1046 
    1047     function addCall()
    1048     {
     893    function addCall() {
    1049894        $args = func_get_args();
    1050895        $methodName = array_shift($args);
     
    1055900        $this->calls[] = $struct;
    1056901    }
    1057 
    1058     function query()
    1059     {
     902    function query() {
    1060903        // Prepare multicall, then call the parent::query() method
    1061904        return parent::query('system.multicall', $this->calls);
Note: See TracChangeset for help on using the changeset viewer.