xmlrpc.inc.php File Reference

Go to the source code of this file.

Classes

class  xmlrpc_client
class  xmlrpcresp
class  xmlrpcmsg
class  xmlrpcval

Functions

 xmlrpc_encode_entitites ($data, $src_encoding='', $dest_encoding='')
 xmlrpc_se ($parser, $name, $attrs, $accept_single_vals=false)
 xml parser handler function for opening element tags
 xmlrpc_se_any ($parser, $name, $attrs)
 Used in decoding xml chunks that might represent single xmlrpc values.
 xmlrpc_ee ($parser, $name, $rebuild_xmlrpcvals=true)
 xml parser handler function for close element tags
 xmlrpc_ee_fast ($parser, $name)
 Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values.
 xmlrpc_cd ($parser, $data)
 xml parser handler function for character data
 xmlrpc_dh ($parser, $data)
 iso8601_encode ($timet, $utc=0)
 iso8601_decode ($idate, $utc=0)
 php_xmlrpc_decode ($xmlrpc_val, $options=array())

Variables

 $phpversion = phpversion()
 $GLOBALS ['xmlrpcI4'] = 'i4'
 $GLOBALS ['xmlrpcInt'] = 'int'
 $GLOBALS ['xmlrpcBoolean'] = 'boolean'
 $GLOBALS ['xmlrpcDouble'] = 'double'
 $GLOBALS ['xmlrpcString'] = 'string'
 $GLOBALS ['xmlrpcDateTime'] = 'dateTime.iso8601'
 $GLOBALS ['xmlrpcBase64'] = 'base64'
 $GLOBALS ['xmlrpcArray'] = 'array'
 $GLOBALS ['xmlrpcStruct'] = 'struct'
 $GLOBALS ['xmlrpcValue'] = 'undefined'
 $GLOBALS ['xmlrpcTypes']
 $GLOBALS ['xmlrpc_valid_parents']
 $GLOBALS ['xmlrpcNull'] = 'null'
 $GLOBALS ['xmlrpcTypes']['null'] = 1
 $GLOBALS ['xmlEntities']
 $GLOBALS ['xml_iso88591_Entities'] = array()
 $GLOBALS ['xml_iso88591_Entities']['in'] = array()
 $GLOBALS ['xml_iso88591_Entities']['out'] = array()
 $GLOBALS ['xml_iso88591_Entities']['out'][] = '&#'.$i.';'
 $GLOBALS ['xmlrpcerr']['unknown_method'] = 1
 $GLOBALS ['xmlrpcstr']['unknown_method'] = 'Unknown method'
 $GLOBALS ['xmlrpcerr']['invalid_return'] = 2
 $GLOBALS ['xmlrpcstr']['invalid_return'] = 'Invalid return payload: enable debugging to examine incoming payload'
 $GLOBALS ['xmlrpcerr']['incorrect_params'] = 3
 $GLOBALS ['xmlrpcstr']['incorrect_params'] = 'Incorrect parameters passed to method'
 $GLOBALS ['xmlrpcerr']['introspect_unknown'] = 4
 $GLOBALS ['xmlrpcstr']['introspect_unknown'] = "Can't introspect: method unknown"
 $GLOBALS ['xmlrpcerr']['http_error'] = 5
 $GLOBALS ['xmlrpcstr']['http_error'] = "Didn't receive 200 OK from remote server."
 $GLOBALS ['xmlrpcerr']['no_data'] = 6
 $GLOBALS ['xmlrpcstr']['no_data'] = 'No data received from server.'
 $GLOBALS ['xmlrpcerr']['no_ssl'] = 7
 $GLOBALS ['xmlrpcstr']['no_ssl'] = 'No SSL support compiled in.'
 $GLOBALS ['xmlrpcerr']['curl_fail'] = 8
 $GLOBALS ['xmlrpcstr']['curl_fail'] = 'CURL error'
 $GLOBALS ['xmlrpcerr']['invalid_request'] = 15
 $GLOBALS ['xmlrpcstr']['invalid_request'] = 'Invalid request payload'
 $GLOBALS ['xmlrpcerr']['no_curl'] = 16
 $GLOBALS ['xmlrpcstr']['no_curl'] = 'No CURL support compiled in.'
 $GLOBALS ['xmlrpcerr']['server_error'] = 17
 $GLOBALS ['xmlrpcstr']['server_error'] = 'Internal server error'
 $GLOBALS ['xmlrpcerr']['multicall_error'] = 18
 $GLOBALS ['xmlrpcstr']['multicall_error'] = 'Received from server invalid multicall response'
 $GLOBALS ['xmlrpcerr']['multicall_notstruct'] = 9
 $GLOBALS ['xmlrpcstr']['multicall_notstruct'] = 'system.multicall expected struct'
 $GLOBALS ['xmlrpcerr']['multicall_nomethod'] = 10
 $GLOBALS ['xmlrpcstr']['multicall_nomethod'] = 'missing methodName'
 $GLOBALS ['xmlrpcerr']['multicall_notstring'] = 11
 $GLOBALS ['xmlrpcstr']['multicall_notstring'] = 'methodName is not a string'
 $GLOBALS ['xmlrpcerr']['multicall_recursion'] = 12
 $GLOBALS ['xmlrpcstr']['multicall_recursion'] = 'recursive system.multicall forbidden'
 $GLOBALS ['xmlrpcerr']['multicall_noparams'] = 13
 $GLOBALS ['xmlrpcstr']['multicall_noparams'] = 'missing params'
 $GLOBALS ['xmlrpcerr']['multicall_notarray'] = 14
 $GLOBALS ['xmlrpcstr']['multicall_notarray'] = 'params is not an array'
 $GLOBALS ['xmlrpcerr']['cannot_decompress'] = 103
 $GLOBALS ['xmlrpcstr']['cannot_decompress'] = 'Received from server compressed HTTP and cannot decompress'
 $GLOBALS ['xmlrpcerr']['decompress_fail'] = 104
 $GLOBALS ['xmlrpcstr']['decompress_fail'] = 'Received from server invalid compressed HTTP'
 $GLOBALS ['xmlrpcerr']['dechunk_fail'] = 105
 $GLOBALS ['xmlrpcstr']['dechunk_fail'] = 'Received from server invalid chunked HTTP'
 $GLOBALS ['xmlrpcerr']['server_cannot_decompress'] = 106
 $GLOBALS ['xmlrpcstr']['server_cannot_decompress'] = 'Received from client compressed HTTP request and cannot decompress'
 $GLOBALS ['xmlrpcerr']['server_decompress_fail'] = 107
 $GLOBALS ['xmlrpcstr']['server_decompress_fail'] = 'Received from client invalid compressed HTTP request'
 $GLOBALS ['xmlrpc_defencoding'] = 'UTF-8'
 $GLOBALS ['xmlrpc_internalencoding'] = 'ISO-8859-1'
 $GLOBALS ['xmlrpcName'] = 'XML-RPC for PHP'
 $GLOBALS ['xmlrpcVersion'] = '2.2'
 $GLOBALS ['xmlrpcerruser'] = 800
 $GLOBALS ['xmlrpcerrxml'] = 100
 $GLOBALS ['xmlrpc_backslash'] = chr(92).chr(92)
 $GLOBALS ['xmlrpc_null_extension'] = false
 $GLOBALS ['_xh'] = null


Function Documentation

iso8601_decode ( idate,
utc = 0 
)

Given an ISO8601 date string, return a timet in the localtime, or UTC

Parameters:
string $idate
int $utc either 0 or 1
Returns:
int (datetime)

Definition at line 3153 of file xmlrpc.inc.php.

Referenced by php_xmlrpc_decode().

iso8601_encode ( timet,
utc = 0 
)

Given a timestamp, return the corresponding ISO8601 encoded string.

Really, timezones ought to be supported but the XML-RPC spec says:

"Don't assume a timezone. It should be specified by the server in its documentation what assumptions it makes about timezones."

These routines always assume localtime unless $utc is set to 1, in which case UTC is assumed and an adjustment for locale is made when encoding

Parameters:
int $timet (timestamp)
int $utc (0 or 1)
Returns:
string

Definition at line 3125 of file xmlrpc.inc.php.

Referenced by _getItem(), _getItemBlogger(), _getRecentItems(), _getRecentItemsBlogger(), _getRecentItemsMetaWeblog(), _mt_getRecentPostTitles(), and _mw_getPost().

php_xmlrpc_decode ( xmlrpc_val,
options = array() 
)

Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.

Works with xmlrpc message objects as input, too.

Given proper options parameter, can rebuild generic php object instances (provided those have been encoded to xmlrpc format using a corresponding option in php_xmlrpc_encode()) PLEASE NOTE that rebuilding php objects involves calling their constructor function. This means that the remote communication end can decide which php code will get executed on your server, leaving the door possibly open to 'php-injection' style of attacks (provided you have some classes defined on your server that might wreak havoc if instances are built outside an appropriate context). Make sure you trust the remote server/client before eanbling this!

Author:
Dan Libby (dan@libby.com)
Parameters:
xmlrpcval $xmlrpc_val
array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects
Returns:
mixed

Todo:
should we raise a warning for class not found?

Definition at line 3191 of file xmlrpc.inc.php.

References iso8601_decode().

xmlrpc_cd ( parser,
data 
)

xml parser handler function for character data

Definition at line 749 of file xmlrpc.inc.php.

References $GLOBALS.

xmlrpc_dh ( parser,
data 
)

xml parser handler function for 'other stuff', ie. not char data or element start/end tag. In fact it only gets called on unknown entities...

Definition at line 777 of file xmlrpc.inc.php.

References $GLOBALS.

xmlrpc_ee ( parser,
name,
rebuild_xmlrpcvals = true 
)

xml parser handler function for close element tags

Todo:
this needs to treat correctly php-serialized objects, since std deserializing is done by php_xmlrpc_decode, which we will not be calling...

Todo:
: optimization creep - remove the if/elseif cycle below

since the case() in which we are already did that

Todo:
check for failure of base64 decoding / catch warnings

Todo:
: find a better way of throwing an error

Todo:
find a better way of throwing an error

Definition at line 534 of file xmlrpc.inc.php.

References $GLOBALS.

Referenced by xmlrpc_ee_fast().

xmlrpc_ee_fast ( parser,
name 
)

Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values.

Definition at line 743 of file xmlrpc.inc.php.

References xmlrpc_ee().

xmlrpc_encode_entitites ( data,
src_encoding = '',
dest_encoding = '' 
)

Convert a string to the correct XML representation in a target charset To help correct communication of non-ascii chars inside strings, regardless of the charset used when sending requests, parsing them, sending responses and parsing responses, an option is to convert all non-ascii chars present in the message into their equivalent 'charset entity'. Charset entities enumerated this way are independent of the charset encoding used to transmit them, and all XML parsers are bound to understand them. Note that in the std case we are not sending a charset encoding mime type along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.

Todo:
do a bit of basic benchmarking (strtr vs. str_replace)
Todo:
make usage of iconv() or recode_string() or mb_string() where available

Todo:
shall we replace this with a (supposedly) faster str_replace?

Definition at line 270 of file xmlrpc.inc.php.

References $GLOBALS.

Referenced by xmlrpcval::serializedata(), and xmlrpc_server::serializeDebug().

xmlrpc_se ( parser,
name,
attrs,
accept_single_vals = false 
)

xml parser handler function for opening element tags

Todo:
optimization creep: save this check into a bool variable, instead of using count() every time: there is only a single top level element in xml anyway

Todo:
we could check for 2 VALUE elements inside a MEMBER or PARAM element

Todo:
we could check for 2 NAME elements inside a MEMBER element

INVALID ELEMENT: RAISE ISF so that it is later recognized!!!

Todo:
optimization creep: move this inside the big switch() above

Definition at line 382 of file xmlrpc.inc.php.

References $GLOBALS.

Referenced by xmlrpc_se_any().

xmlrpc_se_any ( parser,
name,
attrs 
)

Used in decoding xml chunks that might represent single xmlrpc values.

Definition at line 528 of file xmlrpc.inc.php.

References xmlrpc_se().


Variable Documentation

$GLOBALS['_xh'] = null

Definition at line 254 of file xmlrpc.inc.php.

$GLOBALS['xmlrpc_null_extension'] = false

Definition at line 241 of file xmlrpc.inc.php.

$GLOBALS['xmlrpc_backslash'] = chr(92).chr(92)

Deprecated:

Definition at line 238 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerrxml'] = 100

Definition at line 233 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerruser'] = 800

Definition at line 231 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcVersion'] = '2.2'

Definition at line 228 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcName'] = 'XML-RPC for PHP'

Definition at line 227 of file xmlrpc.inc.php.

$GLOBALS['xmlrpc_internalencoding'] = 'ISO-8859-1'

Definition at line 225 of file xmlrpc.inc.php.

$GLOBALS['xmlrpc_defencoding'] = 'UTF-8'

Definition at line 220 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['server_decompress_fail'] = 'Received from client invalid compressed HTTP request'

Definition at line 215 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['server_decompress_fail'] = 107

Definition at line 214 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['server_cannot_decompress'] = 'Received from client compressed HTTP request and cannot decompress'

Definition at line 213 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['server_cannot_decompress'] = 106

Definition at line 212 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['dechunk_fail'] = 'Received from server invalid chunked HTTP'

Definition at line 211 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['dechunk_fail'] = 105

Definition at line 210 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['decompress_fail'] = 'Received from server invalid compressed HTTP'

Definition at line 209 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['decompress_fail'] = 104

Definition at line 208 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['cannot_decompress'] = 'Received from server compressed HTTP and cannot decompress'

Definition at line 207 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['cannot_decompress'] = 103

Definition at line 206 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_notarray'] = 'params is not an array'

Definition at line 204 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_notarray'] = 14

Definition at line 203 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_noparams'] = 'missing params'

Definition at line 202 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_noparams'] = 13

Definition at line 201 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_recursion'] = 'recursive system.multicall forbidden'

Definition at line 200 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_recursion'] = 12

Definition at line 199 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_notstring'] = 'methodName is not a string'

Definition at line 198 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_notstring'] = 11

Definition at line 197 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_nomethod'] = 'missing methodName'

Definition at line 196 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_nomethod'] = 10

Definition at line 195 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_notstruct'] = 'system.multicall expected struct'

Definition at line 194 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_notstruct'] = 9

Definition at line 193 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['multicall_error'] = 'Received from server invalid multicall response'

Definition at line 191 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['multicall_error'] = 18

Definition at line 190 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['server_error'] = 'Internal server error'

Definition at line 189 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['server_error'] = 17

Definition at line 188 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['no_curl'] = 'No CURL support compiled in.'

Definition at line 187 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['no_curl'] = 16

Definition at line 186 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['invalid_request'] = 'Invalid request payload'

Definition at line 185 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['invalid_request'] = 15

Definition at line 184 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['curl_fail'] = 'CURL error'

Definition at line 183 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['curl_fail'] = 8

Definition at line 182 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['no_ssl'] = 'No SSL support compiled in.'

Definition at line 181 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['no_ssl'] = 7

Definition at line 180 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['no_data'] = 'No data received from server.'

Definition at line 179 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['no_data'] = 6

Definition at line 178 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['http_error'] = "Didn't receive 200 OK from remote server."

Definition at line 177 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['http_error'] = 5

Definition at line 176 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['introspect_unknown'] = "Can't introspect: method unknown"

Definition at line 175 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['introspect_unknown'] = 4

Definition at line 174 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['incorrect_params'] = 'Incorrect parameters passed to method'

Definition at line 173 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['incorrect_params'] = 3

Definition at line 172 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['invalid_return'] = 'Invalid return payload: enable debugging to examine incoming payload'

Definition at line 171 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['invalid_return'] = 2

Definition at line 170 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcstr']['unknown_method'] = 'Unknown method'

Definition at line 169 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcerr']['unknown_method'] = 1

Todo:
add to iso table the characters from cp_1252 range, i.e. 128 to 159. These will NOT be present in true ISO-8859-1, but will save the unwary windows user from sending junk.

Definition at line 168 of file xmlrpc.inc.php.

$GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'

Definition at line 143 of file xmlrpc.inc.php.

$GLOBALS['xml_iso88591_Entities']['out'] = array()

Definition at line 139 of file xmlrpc.inc.php.

$GLOBALS['xml_iso88591_Entities']['in'] = array()

Definition at line 138 of file xmlrpc.inc.php.

$GLOBALS['xml_iso88591_Entities'] = array()

Definition at line 137 of file xmlrpc.inc.php.

$GLOBALS['xmlEntities']

Initial value:

array(
                'amp'  => '&',
                'quot' => '"',
                'lt'   => '<',
                'gt'   => '>',
                'apos' => "'"
        )
Deprecated:

Definition at line 127 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcTypes']['null'] = 1

Definition at line 123 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcNull'] = 'null'

Definition at line 122 of file xmlrpc.inc.php.

$GLOBALS['xmlrpc_valid_parents']

Initial value:

 array(
                'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
                'BOOLEAN' => array('VALUE'),
                'I4' => array('VALUE'),
                'INT' => array('VALUE'),
                'STRING' => array('VALUE'),
                'DOUBLE' => array('VALUE'),
                'DATETIME.ISO8601' => array('VALUE'),
                'BASE64' => array('VALUE'),
                'MEMBER' => array('STRUCT'),
                'NAME' => array('MEMBER'),
                'DATA' => array('ARRAY'),
                'ARRAY' => array('VALUE'),
                'STRUCT' => array('VALUE'),
                'PARAM' => array('PARAMS'),
                'METHODNAME' => array('METHODCALL'),
                'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
                'FAULT' => array('METHODRESPONSE'),
                'NIL' => array('VALUE') // only used when extension activated
        )

Definition at line 100 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcTypes']

Initial value:

array(
                $GLOBALS['xmlrpcI4']       => 1,
                $GLOBALS['xmlrpcInt']      => 1,
                $GLOBALS['xmlrpcBoolean']  => 1,
                $GLOBALS['xmlrpcString']   => 1,
                $GLOBALS['xmlrpcDouble']   => 1,
                $GLOBALS['xmlrpcDateTime'] => 1,
                $GLOBALS['xmlrpcBase64']   => 1,
                $GLOBALS['xmlrpcArray']    => 2,
                $GLOBALS['xmlrpcStruct']   => 3
        )

Definition at line 88 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcValue'] = 'undefined'

Definition at line 86 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcStruct'] = 'struct'

Definition at line 85 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcArray'] = 'array'

Definition at line 84 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcBase64'] = 'base64'

Definition at line 83 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcDateTime'] = 'dateTime.iso8601'

Definition at line 82 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcString'] = 'string'

Definition at line 81 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcDouble'] = 'double'

Definition at line 80 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcBoolean'] = 'boolean'

Definition at line 79 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcInt'] = 'int'

Definition at line 78 of file xmlrpc.inc.php.

$GLOBALS['xmlrpcI4'] = 'i4'

$phpversion = phpversion()

Definition at line 52 of file xmlrpc.inc.php.



Generated on Wed Jun 25 17:26:01 2008 by  doxygen 1.5.5