WordPress.org

Make WordPress Core

Changeset 2622


Ignore:
Timestamp:
06/07/2005 07:39:39 AM (14 years ago)
Author:
matt
Message:

Updating IXR to latest, fixes #1400

File:
1 edited

Legend:

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

    r2139 r2622  
    11<?php
    2 
    32/*
    4    IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
    5    Version 1.62WP - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
    6            ^^^^^^ (We've made some changes)
     3   IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002-2005
     4   Version 1.7 (beta) - Simon Willison, 23rd May 2005
    75   Site:   http://scripts.incutio.com/xmlrpc/
    86   Manual: http://scripts.incutio.com/xmlrpc/manual.php
    97   Made available under the BSD License: http://www.opensource.org/licenses/bsd-license.php
    108*/
    11 
    129
    1310class IXR_Value {
     
    9188                $return = '<struct>'."\n";
    9289                foreach ($this->data as $name => $value) {
     90                    $name = htmlspecialchars($name);
    9391                    $return .= "  <member><name>$name</name><value>";
    9492                    $return .= $value->getXml()."</value></member>\n";
     
    166164    }
    167165    function tag_open($parser, $tag, $attr) {
     166        $this->_currentTagContents = '';
    168167        $this->currentTag = $tag;
    169168        switch($tag) {
     
    192191            case 'int':
    193192            case 'i4':
    194                 $value = (int)trim($this->_currentTagContents);
    195                 $this->_currentTagContents = '';
     193                $value = (int) trim($this->_currentTagContents);
    196194                $valueFlag = true;
    197195                break;
    198196            case 'double':
    199                 $value = (double)trim($this->_currentTagContents);
    200                 $this->_currentTagContents = '';
     197                $value = (double) trim($this->_currentTagContents);
    201198                $valueFlag = true;
    202199                break;
    203200            case 'string':
    204                 $value = (string)trim($this->_currentTagContents);
    205                 $this->_currentTagContents = '';
     201                $value = $this->_currentTagContents;
    206202                $valueFlag = true;
    207203                break;
     
    209205                $value = new IXR_Date(trim($this->_currentTagContents));
    210206                // $value = $iso->getTimestamp();
    211                 $this->_currentTagContents = '';
    212207                $valueFlag = true;
    213208                break;
     
    216211                if (trim($this->_currentTagContents) != '') {
    217212                    $value = (string)$this->_currentTagContents;
    218                     $this->_currentTagContents = '';
    219213                    $valueFlag = true;
    220214                }
    221215                break;
    222216            case 'boolean':
    223                 $value = (boolean)trim($this->_currentTagContents);
    224                 $this->_currentTagContents = '';
     217                $value = (boolean) trim($this->_currentTagContents);
    225218                $valueFlag = true;
    226219                break;
    227220            case 'base64':
    228                 $value = base64_decode( trim($this->_currentTagContents) );
    229                 $this->_currentTagContents = '';
     221                $value = base64_decode( trim( $this->_currentTagContents ) );
    230222                $valueFlag = true;
    231223                break;
     
    242234            case 'name':
    243235                $this->_currentStructName[] = trim($this->_currentTagContents);
    244                 $this->_currentTagContents = '';
    245236                break;
    246237            case 'methodName':
    247238                $this->methodName = trim($this->_currentTagContents);
    248                 $this->_currentTagContents = '';
    249239                break;
    250240        }
    251241        if ($valueFlag) {
    252             /*
    253             if (!is_array($value) && !is_object($value)) {
    254                 $value = trim($value);
    255             }
    256             */
    257242            if (count($this->_arraystructs) > 0) {
    258243                // Add value to struct or array
     
    269254            }
    270255        }
     256        $this->_currentTagContents = '';
    271257    }       
    272258}
     
    470456    var $useragent;
    471457    var $response;
    472     var $timeout;
    473     var $vendor = '';
    474458    var $message = false;
    475459    var $debug = false;
     460    var $timeout;
    476461    // Storage place for an error message
    477462    var $error = false;
    478     function IXR_Client($server, $path = false, $port = 80, $timeout = 30, $vendor = '') {
     463    function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
    479464        if (!$path) {
    480465            // Assume we have been given a URL instead
     
    491476            $this->path = $path;
    492477            $this->port = $port;
    493             $this->timeout = $timeout;
    494         }
    495         $this->useragent = 'The Incutio XML-RPC PHP Library';
     478        }
     479        $this->useragent = 'Incutio XML-RPC';
     480        $this->timeout = $timeout;
    496481    }
    497482    function query() {
     
    512497            echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
    513498        }
    514         $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
     499        if ($this->timeout) {
     500            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
     501        } else {
     502            $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
     503        }
    515504        if (!$fp) {
    516             $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
     505            $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
    517506            return false;
    518507        }
     
    611600    var $minute;
    612601    var $second;
    613     var $timezone;
    614602    function IXR_Date($time) {
    615603        // $time can be a PHP timestamp or an ISO one
     
    622610    function parseTimestamp($timestamp) {
    623611        $this->year = date('Y', $timestamp);
    624         $this->month = date('Y', $timestamp);
    625         $this->day = date('Y', $timestamp);
     612        $this->month = date('m', $timestamp);
     613        $this->day = date('d', $timestamp);
    626614        $this->hour = date('H', $timestamp);
    627615        $this->minute = date('i', $timestamp);
     
    638626    }
    639627    function getIso() {
    640         return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
     628        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
    641629    }
    642630    function getXml() {
     
    714702        // Check the number of arguments
    715703        if (count($args) != count($signature)) {
    716             // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
    717704            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
    718705        }
Note: See TracChangeset for help on using the changeset viewer.