Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r14677 r16809  
    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        $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
    186235        // Grab the error messages, if any
    187236        if ($this->messageType == 'fault') {
    188237            $this->faultCode = $this->params[0]['faultCode'];
    189238            $this->faultString = $this->params[0]['faultString'];
    190         }
     239        }
    191240        return true;
    192241    }
    193     function tag_open($parser, $tag, $attr) {
     242
     243    function tag_open($parser, $tag, $attr)
     244    {
    194245        $this->_currentTagContents = '';
    195246        $this->currentTag = $tag;
     
    200251                $this->messageType = $tag;
    201252                break;
    202             /* Deal with stacks of arrays and structs */
     253                /* Deal with stacks of arrays and structs */
    203254            case 'data':    // data is to all intents and puposes more interesting than array
    204255                $this->_arraystructstypes[] = 'array';
     
    211262        }
    212263    }
    213     function cdata($parser, $cdata) {
     264
     265    function cdata($parser, $cdata)
     266    {
    214267        $this->_currentTagContents .= $cdata;
    215268    }
    216     function tag_close($parser, $tag) {
     269
     270    function tag_close($parser, $tag)
     271    {
    217272        $valueFlag = false;
    218273        switch($tag) {
    219274            case 'int':
    220275            case 'i4':
    221                 $value = (int) trim($this->_currentTagContents);
     276                $value = (int)trim($this->_currentTagContents);
    222277                $valueFlag = true;
    223278                break;
    224279            case 'double':
    225                 $value = (double) trim($this->_currentTagContents);
     280                $value = (double)trim($this->_currentTagContents);
    226281                $valueFlag = true;
    227282                break;
    228283            case 'string':
    229                 $value = $this->_currentTagContents;
     284                $value = (string)trim($this->_currentTagContents);
    230285                $valueFlag = true;
    231286                break;
    232287            case 'dateTime.iso8601':
    233288                $value = new IXR_Date(trim($this->_currentTagContents));
    234                 // $value = $iso->getTimestamp();
    235289                $valueFlag = true;
    236290                break;
     
    243297                break;
    244298            case 'boolean':
    245                 $value = (boolean) trim($this->_currentTagContents);
     299                $value = (boolean)trim($this->_currentTagContents);
    246300                $valueFlag = true;
    247301                break;
    248302            case 'base64':
    249                 $value = base64_decode( trim( $this->_currentTagContents ) );
     303                $value = base64_decode($this->_currentTagContents);
    250304                $valueFlag = true;
    251305                break;
    252             /* Deal with stacks of arrays and structs */
     306                /* Deal with stacks of arrays and structs */
    253307            case 'data':
    254308            case 'struct':
     
    267321                break;
    268322        }
     323
    269324        if ($valueFlag) {
    270325            if (count($this->_arraystructs) > 0) {
     
    292347 * @since 1.5
    293348 */
    294 class IXR_Server {
     349class IXR_Server
     350{
    295351    var $data;
    296352    var $callbacks = array();
    297353    var $message;
    298354    var $capabilities;
    299     function IXR_Server($callbacks = false, $data = false) {
     355
     356    function IXR_Server($callbacks = false, $data = false, $wait = false)
     357    {
    300358        $this->setCapabilities();
    301359        if ($callbacks) {
     
    303361        }
    304362        $this->setCallbacks();
    305         $this->serve($data);
    306     }
    307     function serve($data = false) {
     363        if (!$wait) {
     364            $this->serve($data);
     365        }
     366    }
     367
     368    function serve($data = false)
     369    {
    308370        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
    309376            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;
     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            }
    315383        }
    316384        $this->message = new IXR_Message($data);
     
    322390        }
    323391        $result = $this->call($this->message->methodName, $this->message->params);
     392
    324393        // Is the result an error?
    325394        if (is_a($result, 'IXR_Error')) {
    326395            $this->error($result);
    327396        }
     397
    328398        // Encode the result
    329399        $r = new IXR_Value($result);
    330400        $resultxml = $r->getXml();
     401
    331402        // Create the XML
    332403        $xml = <<<EOD
     
    335406    <param>
    336407      <value>
    337         $resultxml
     408      $resultxml
    338409      </value>
    339410    </param>
     
    342413
    343414EOD;
    344         // Send it
    345         $this->output($xml);
    346     }
    347     function call($methodname, $args) {
     415      // Send it
     416      $this->output($xml);
     417    }
     418
     419    function call($methodname, $args)
     420    {
    348421        if (!$this->hasMethod($methodname)) {
    349             return new IXR_Error(-32601, 'server error. requested method '.
    350                 $methodname.' does not exist.');
     422            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
    351423        }
    352424        $method = $this->callbacks[$methodname];
     425
    353426        // Perform the callback and send the response
    354427        if (count($args) == 1) {
     
    356429            $args = $args[0];
    357430        }
     431
    358432        // Are we dealing with a function or a method?
    359         if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) {
     433        if (is_string($method) && substr($method, 0, 5) == 'this:') {
    360434            // It's a class method - check it exists
    361435            $method = substr($method, 5);
    362436            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
     437                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
     438            }
     439
     440            //Call the method
    367441            $result = $this->$method($args);
    368442        } else {
    369443            // It's a function - does it exist?
    370444            if (is_array($method)) {
    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.');
     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.');
    374447                }
    375448            } else if (!function_exists($method)) {
    376                 return new IXR_Error(-32601, 'server error. requested function "'.
    377                     $method.'" does not exist.');
    378             }
     449                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
     450            }
     451
    379452            // Call the function
    380453            $result = call_user_func($method, $args);
     
    383456    }
    384457
    385     function error($error, $message = false) {
     458    function error($error, $message = false)
     459    {
    386460        // Accepts either an error object or an error code and message
    387461        if ($message && !is_object($error)) {
     
    390464        $this->output($error->getXml());
    391465    }
    392     function output($xml) {
     466
     467    function output($xml)
     468    {
    393469        $xml = '<?xml version="1.0"?>'."\n".$xml;
    394470        $length = strlen($xml);
     
    400476        exit;
    401477    }
    402     function hasMethod($method) {
     478
     479    function hasMethod($method)
     480    {
    403481        return in_array($method, array_keys($this->callbacks));
    404482    }
    405     function setCapabilities() {
     483
     484    function setCapabilities()
     485    {
    406486        // Initialises capabilities array
    407487        $this->capabilities = array(
     
    409489                'specUrl' => 'http://www.xmlrpc.com/spec',
    410490                'specVersion' => 1
    411             ),
     491        ),
    412492            'faults_interop' => array(
    413493                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
    414494                'specVersion' => 20010516
    415             ),
     495        ),
    416496            'system.multicall' => array(
    417497                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
    418498                'specVersion' => 1
    419             ),
     499        ),
    420500        );
    421501    }
    422     function getCapabilities($args) {
     502
     503    function getCapabilities($args)
     504    {
    423505        return $this->capabilities;
    424506    }
    425     function setCallbacks() {
     507
     508    function setCallbacks()
     509    {
    426510        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
    427511        $this->callbacks['system.listMethods'] = 'this:listMethods';
    428512        $this->callbacks['system.multicall'] = 'this:multiCall';
    429513    }
    430     function listMethods($args) {
     514
     515    function listMethods($args)
     516    {
    431517        // Returns a list of methods - uses array_reverse to ensure user defined
    432518        // methods are listed before server defined methods
    433519        return array_reverse(array_keys($this->callbacks));
    434520    }
    435     function multiCall($methodcalls) {
     521
     522    function multiCall($methodcalls)
     523    {
    436524        // See http://www.xmlrpc.com/discuss/msgReader$1208
    437525        $return = array();
     
    463551 * @since 1.5
    464552 */
    465 class IXR_Request {
     553class IXR_Request
     554{
    466555    var $method;
    467556    var $args;
    468557    var $xml;
    469     function IXR_Request($method, $args) {
     558
     559    function IXR_Request($method, $args)
     560    {
    470561        $this->method = $method;
    471562        $this->args = $args;
     
    485576        $this->xml .= '</params></methodCall>';
    486577    }
    487     function getLength() {
     578
     579    function getLength()
     580    {
    488581        return strlen($this->xml);
    489582    }
    490     function getXml() {
     583
     584    function getXml()
     585    {
    491586        return $this->xml;
    492587    }
     
    498593 * @package IXR
    499594 * @since 1.5
     595 *
    500596 */
    501 class IXR_Client {
     597class IXR_Client
     598{
    502599    var $server;
    503600    var $port;
    504601    var $path;
    505602    var $useragent;
    506     var $headers;
    507603    var $response;
    508604    var $message = false;
    509605    var $debug = false;
    510606    var $timeout;
     607    var $headers = array();
     608
    511609    // Storage place for an error message
    512610    var $error = false;
    513     function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
     611
     612    function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
     613    {
    514614        if (!$path) {
    515615            // Assume we have been given a URL instead
     
    518618            $this->port = isset($bits['port']) ? $bits['port'] : 80;
    519619            $this->path = isset($bits['path']) ? $bits['path'] : '/';
     620
    520621            // Make absolutely sure we have a path
    521622            if (!$this->path) {
     
    530631        $this->timeout = $timeout;
    531632    }
    532     function query() {
     633
     634    function query()
     635    {
    533636        $args = func_get_args();
    534637        $method = array_shift($args);
     
    539642        $request  = "POST {$this->path} HTTP/1.0$r";
    540643
    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;
     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;
    550654
    551655        $request .= $xml;
     656
    552657        // Now send the request
    553658        if ($this->debug) {
    554659            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
    555660        }
     661
    556662        if ($this->timeout) {
    557663            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
     
    560666        }
    561667        if (!$fp) {
    562             $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
     668            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
    563669            return false;
    564670        }
    565671        fputs($fp, $request);
    566672        $contents = '';
    567         $debug_contents = '';
     673        $debugContents = '';
    568674        $gotFirstLine = false;
    569675        $gettingHeaders = true;
     
    573679                // Check line for '200'
    574680                if (strstr($line, '200') === false) {
    575                     $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
     681                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
    576682                    return false;
    577683                }
     
    582688            }
    583689            if (!$gettingHeaders) {
    584                 // WP#12559 remove trim so as to not strip newlines from received response.
     690                // merged from WP #12559 - remove trim
    585691                $contents .= $line;
    586692            }
    587693            if ($this->debug) {
    588                 $debug_contents .= $line;
     694                $debugContents .= $line;
    589695            }
    590696        }
    591697        if ($this->debug) {
    592             echo '<pre class="ixr_response">'.htmlspecialchars($debug_contents)."\n</pre>\n\n";
    593         }
     698            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
     699        }
     700
    594701        // Now parse what we've got back
    595702        $this->message = new IXR_Message($contents);
     
    599706            return false;
    600707        }
     708
    601709        // Is the message a fault?
    602710        if ($this->message->messageType == 'fault') {
     
    604712            return false;
    605713        }
     714
    606715        // Message must be OK
    607716        return true;
    608717    }
    609     function getResponse() {
     718
     719    function getResponse()
     720    {
    610721        // methodResponses can only have one param - return that
    611722        return $this->message->params[0];
    612723    }
    613     function isError() {
     724
     725    function isError()
     726    {
    614727        return (is_object($this->error));
    615728    }
    616     function getErrorCode() {
     729
     730    function getErrorCode()
     731    {
    617732        return $this->error->code;
    618733    }
    619     function getErrorMessage() {
     734
     735    function getErrorMessage()
     736    {
    620737        return $this->error->message;
    621738    }
    622739}
     740
    623741
    624742/**
     
    628746 * @since 1.5
    629747 */
    630 class IXR_Error {
     748class IXR_Error
     749{
    631750    var $code;
    632751    var $message;
    633     function IXR_Error($code, $message) {
     752
     753    function IXR_Error($code, $message)
     754    {
    634755        $this->code = $code;
    635         // WP adds htmlspecialchars(). See #5666
    636756        $this->message = htmlspecialchars($message);
    637757    }
    638     function getXml() {
     758
     759    function getXml()
     760    {
    639761        $xml = <<<EOD
    640762<methodResponse>
     
    674796    var $second;
    675797    var $timezone;
    676     function IXR_Date($time) {
     798
     799    function IXR_Date($time)
     800    {
    677801        // $time can be a PHP timestamp or an ISO one
    678802        if (is_numeric($time)) {
     
    682806        }
    683807    }
    684     function parseTimestamp($timestamp) {
     808
     809    function parseTimestamp($timestamp)
     810    {
    685811        $this->year = date('Y', $timestamp);
    686812        $this->month = date('m', $timestamp);
     
    689815        $this->minute = date('i', $timestamp);
    690816        $this->second = date('s', $timestamp);
    691         // WP adds timezone. See #2036
    692817        $this->timezone = '';
    693818    }
    694     function parseIso($iso) {
     819
     820    function parseIso($iso)
     821    {
    695822        $this->year = substr($iso, 0, 4);
    696823        $this->month = substr($iso, 4, 2);
     
    699826        $this->minute = substr($iso, 12, 2);
    700827        $this->second = substr($iso, 15, 2);
    701         // WP adds timezone. See #2036
    702828        $this->timezone = substr($iso, 17);
    703829    }
    704     function getIso() {
    705         // WP adds timezone. See #2036
     830
     831    function getIso()
     832    {
    706833        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
    707834    }
    708     function getXml() {
     835
     836    function getXml()
     837    {
    709838        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
    710839    }
    711     function getTimestamp() {
     840
     841    function getTimestamp()
     842    {
    712843        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
    713844    }
     
    720851 * @since 1.5
    721852 */
    722 class IXR_Base64 {
     853class IXR_Base64
     854{
    723855    var $data;
    724     function IXR_Base64($data) {
     856
     857    function IXR_Base64($data)
     858    {
    725859        $this->data = $data;
    726860    }
    727     function getXml() {
     861
     862    function getXml()
     863    {
    728864        return '<base64>'.base64_encode($this->data).'</base64>';
    729865    }
     
    736872 * @since 1.5
    737873 */
    738 class IXR_IntrospectionServer extends IXR_Server {
     874class IXR_IntrospectionServer extends IXR_Server
     875{
    739876    var $signatures;
    740877    var $help;
    741     function IXR_IntrospectionServer() {
     878
     879    function IXR_IntrospectionServer()
     880    {
    742881        $this->setCallbacks();
    743882        $this->setCapabilities();
     
    771910        );
    772911    }
    773     function addCallback($method, $callback, $args, $help) {
     912
     913    function addCallback($method, $callback, $args, $help)
     914    {
    774915        $this->callbacks[$method] = $callback;
    775916        $this->signatures[$method] = $args;
    776917        $this->help[$method] = $help;
    777918    }
    778     function call($methodname, $args) {
     919
     920    function call($methodname, $args)
     921    {
    779922        // Make sure it's in an array
    780923        if ($args && !is_array($args)) {
    781924            $args = array($args);
    782925        }
     926
    783927        // Over-rides default call method, adds signature check
    784928        if (!$this->hasMethod($methodname)) {
     
    788932        $signature = $this->signatures[$methodname];
    789933        $returnType = array_shift($signature);
     934
    790935        // Check the number of arguments
    791936        if (count($args) != count($signature)) {
    792937            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
    793938        }
     939
    794940        // Check the argument types
    795941        $ok = true;
     
    836982        return parent::call($methodname, $argsbackup);
    837983    }
    838     function methodSignature($method) {
     984
     985    function methodSignature($method)
     986    {
    839987        if (!$this->hasMethod($method)) {
    840988            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
     
    8741022        return $return;
    8751023    }
    876     function methodHelp($method) {
     1024
     1025    function methodHelp($method)
     1026    {
    8771027        return $this->help[$method];
    8781028    }
     
    8851035 * @since 1.5
    8861036 */
    887 class IXR_ClientMulticall extends IXR_Client {
     1037class IXR_ClientMulticall extends IXR_Client
     1038{
    8881039    var $calls = array();
    889     function IXR_ClientMulticall($server, $path = false, $port = 80) {
     1040
     1041    function IXR_ClientMulticall($server, $path = false, $port = 80)
     1042    {
    8901043        parent::IXR_Client($server, $path, $port);
    8911044        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
    8921045    }
    893     function addCall() {
     1046
     1047    function addCall()
     1048    {
    8941049        $args = func_get_args();
    8951050        $methodName = array_shift($args);
     
    9001055        $this->calls[] = $struct;
    9011056    }
    902     function query() {
     1057
     1058    function query()
     1059    {
    9031060        // Prepare multicall, then call the parent::query() method
    9041061        return parent::query('system.multicall', $this->calls);
Note: See TracChangeset for help on using the changeset viewer.