Updating IXR to latest, fixes #1400

git-svn-id: http://svn.automattic.com/wordpress/trunk@2622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-06-07 07:39:39 +00:00
parent af28ba7155
commit aa209f78de
1 changed files with 23 additions and 36 deletions

View File

@ -1,15 +1,12 @@
<?php <?php
/* /*
IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002 IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002-2005
Version 1.62WP - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars) Version 1.7 (beta) - Simon Willison, 23rd May 2005
^^^^^^ (We've made some changes)
Site: http://scripts.incutio.com/xmlrpc/ Site: http://scripts.incutio.com/xmlrpc/
Manual: http://scripts.incutio.com/xmlrpc/manual.php Manual: http://scripts.incutio.com/xmlrpc/manual.php
Made available under the BSD License: http://www.opensource.org/licenses/bsd-license.php Made available under the BSD License: http://www.opensource.org/licenses/bsd-license.php
*/ */
class IXR_Value { class IXR_Value {
var $data; var $data;
var $type; var $type;
@ -90,6 +87,7 @@ class IXR_Value {
case 'struct': case 'struct':
$return = '<struct>'."\n"; $return = '<struct>'."\n";
foreach ($this->data as $name => $value) { foreach ($this->data as $name => $value) {
$name = htmlspecialchars($name);
$return .= " <member><name>$name</name><value>"; $return .= " <member><name>$name</name><value>";
$return .= $value->getXml()."</value></member>\n"; $return .= $value->getXml()."</value></member>\n";
} }
@ -165,6 +163,7 @@ class IXR_Message {
return true; return true;
} }
function tag_open($parser, $tag, $attr) { function tag_open($parser, $tag, $attr) {
$this->_currentTagContents = '';
$this->currentTag = $tag; $this->currentTag = $tag;
switch($tag) { switch($tag) {
case 'methodCall': case 'methodCall':
@ -191,42 +190,35 @@ class IXR_Message {
switch($tag) { switch($tag) {
case 'int': case 'int':
case 'i4': case 'i4':
$value = (int)trim($this->_currentTagContents); $value = (int) trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
case 'double': case 'double':
$value = (double)trim($this->_currentTagContents); $value = (double) trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
case 'string': case 'string':
$value = (string)trim($this->_currentTagContents); $value = $this->_currentTagContents;
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
case 'dateTime.iso8601': case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents)); $value = new IXR_Date(trim($this->_currentTagContents));
// $value = $iso->getTimestamp(); // $value = $iso->getTimestamp();
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
case 'value': case 'value':
// "If no type is indicated, the type is string." // "If no type is indicated, the type is string."
if (trim($this->_currentTagContents) != '') { if (trim($this->_currentTagContents) != '') {
$value = (string)$this->_currentTagContents; $value = (string)$this->_currentTagContents;
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
} }
break; break;
case 'boolean': case 'boolean':
$value = (boolean)trim($this->_currentTagContents); $value = (boolean) trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
case 'base64': case 'base64':
$value = base64_decode( trim($this->_currentTagContents) ); $value = base64_decode( trim( $this->_currentTagContents ) );
$this->_currentTagContents = '';
$valueFlag = true; $valueFlag = true;
break; break;
/* Deal with stacks of arrays and structs */ /* Deal with stacks of arrays and structs */
@ -241,19 +233,12 @@ class IXR_Message {
break; break;
case 'name': case 'name':
$this->_currentStructName[] = trim($this->_currentTagContents); $this->_currentStructName[] = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break; break;
case 'methodName': case 'methodName':
$this->methodName = trim($this->_currentTagContents); $this->methodName = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break; break;
} }
if ($valueFlag) { if ($valueFlag) {
/*
if (!is_array($value) && !is_object($value)) {
$value = trim($value);
}
*/
if (count($this->_arraystructs) > 0) { if (count($this->_arraystructs) > 0) {
// Add value to struct or array // Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') { if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
@ -268,6 +253,7 @@ class IXR_Message {
$this->params[] = $value; $this->params[] = $value;
} }
} }
$this->_currentTagContents = '';
} }
} }
@ -469,13 +455,12 @@ class IXR_Client {
var $path; var $path;
var $useragent; var $useragent;
var $response; var $response;
var $timeout;
var $vendor = '';
var $message = false; var $message = false;
var $debug = false; var $debug = false;
var $timeout;
// Storage place for an error message // Storage place for an error message
var $error = false; var $error = false;
function IXR_Client($server, $path = false, $port = 80, $timeout = 30, $vendor = '') { function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
if (!$path) { if (!$path) {
// Assume we have been given a URL instead // Assume we have been given a URL instead
$bits = parse_url($server); $bits = parse_url($server);
@ -490,9 +475,9 @@ class IXR_Client {
$this->server = $server; $this->server = $server;
$this->path = $path; $this->path = $path;
$this->port = $port; $this->port = $port;
$this->timeout = $timeout;
} }
$this->useragent = 'The Incutio XML-RPC PHP Library'; $this->useragent = 'Incutio XML-RPC';
$this->timeout = $timeout;
} }
function query() { function query() {
$args = func_get_args(); $args = func_get_args();
@ -511,9 +496,13 @@ class IXR_Client {
if ($this->debug) { if ($this->debug) {
echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n"; echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
} }
$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); if ($this->timeout) {
$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
} else {
$fp = @fsockopen($this->server, $this->port, $errno, $errstr);
}
if (!$fp) { if (!$fp) {
$this->error = new IXR_Error(-32300, 'transport error - could not open socket'); $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
return false; return false;
} }
fputs($fp, $request); fputs($fp, $request);
@ -610,7 +599,6 @@ class IXR_Date {
var $hour; var $hour;
var $minute; var $minute;
var $second; var $second;
var $timezone;
function IXR_Date($time) { function IXR_Date($time) {
// $time can be a PHP timestamp or an ISO one // $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) { if (is_numeric($time)) {
@ -621,8 +609,8 @@ class IXR_Date {
} }
function parseTimestamp($timestamp) { function parseTimestamp($timestamp) {
$this->year = date('Y', $timestamp); $this->year = date('Y', $timestamp);
$this->month = date('Y', $timestamp); $this->month = date('m', $timestamp);
$this->day = date('Y', $timestamp); $this->day = date('d', $timestamp);
$this->hour = date('H', $timestamp); $this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp); $this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp); $this->second = date('s', $timestamp);
@ -637,7 +625,7 @@ class IXR_Date {
$this->timezone = substr($iso, 17); $this->timezone = substr($iso, 17);
} }
function getIso() { function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
} }
function getXml() { function getXml() {
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>'; return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
@ -713,7 +701,6 @@ class IXR_IntrospectionServer extends IXR_Server {
$returnType = array_shift($signature); $returnType = array_shift($signature);
// Check the number of arguments // Check the number of arguments
if (count($args) != count($signature)) { if (count($args) != count($signature)) {
// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
return new IXR_Error(-32602, 'server error. wrong number of method parameters'); return new IXR_Error(-32602, 'server error. wrong number of method parameters');
} }
// Check the argument types // Check the argument types