<?php
class xmlrpc_client
{
- var $path;
- var $server;
- var $port=0;
- var $method='http';
- var $errno;
- var $errstr;
- var $debug=0;
- var $username='';
- var $password='';
- var $authtype=1;
- var $cert='';
- var $certpass='';
- var $cacert='';
- var $cacertdir='';
- var $key='';
- var $keypass='';
- var $verifypeer=true;
- var $verifyhost=2;
- var $no_multicall=false;
- var $proxy='';
- var $proxyport=0;
- var $proxy_user='';
- var $proxy_pass='';
- var $proxy_authtype=1;
- var $cookies=array();
- var $extracurlopts=array();
+ /// @todo: does these need to be public?
+ public $path;
+ public $server;
+ public $port=0;
+ public $method='http';
+ public $errno;
+ public $errstr;
+ public $debug=0;
+ public $username='';
+ public $password='';
+ public $authtype=1;
+ public $cert='';
+ public $certpass='';
+ public $cacert='';
+ public $cacertdir='';
+ public $key='';
+ public $keypass='';
+ public $verifypeer=true;
+ public $verifyhost=2;
+ public $no_multicall=false;
+ public $proxy='';
+ public $proxyport=0;
+ public $proxy_user='';
+ public $proxy_pass='';
+ public $proxy_authtype=1;
+ public $cookies=array();
+ public $extracurlopts=array();
/**
- * List of http compression methods accepted by the client for responses.
- * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
- *
- * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since
- * in those cases it will be up to CURL to decide the compression methods
- * it supports. You might check for the presence of 'zlib' in the output of
- * curl_version() to determine wheter compression is supported or not
- */
- var $accepted_compression = array();
+ * List of http compression methods accepted by the client for responses.
+ * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
+ *
+ * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since
+ * in those cases it will be up to CURL to decide the compression methods
+ * it supports. You might check for the presence of 'zlib' in the output of
+ * curl_version() to determine wheter compression is supported or not
+ */
+ public $accepted_compression = array();
/**
- * Name of compression scheme to be used for sending requests.
- * Either null, gzip or deflate
- */
- var $request_compression = '';
+ * Name of compression scheme to be used for sending requests.
+ * Either null, gzip or deflate
+ */
+ public $request_compression = '';
/**
- * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
- * http://curl.haxx.se/docs/faq.html#7.3)
- */
- var $xmlrpc_curl_handle = null;
+ * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
+ * http://curl.haxx.se/docs/faq.html#7.3)
+ */
+ public $xmlrpc_curl_handle = null;
/// Whether to use persistent connections for http 1.1 and https
- var $keepalive = false;
+ public $keepalive = false;
/// Charset encodings that can be decoded without problems by the client
- var $accepted_charset_encodings = array();
+ public $accepted_charset_encodings = array();
/// Charset encoding to be used in serializing request. NULL = use ASCII
- var $request_charset_encoding = '';
+ public $request_charset_encoding = '';
/**
- * Decides the content of xmlrpcresp objects returned by calls to send()
- * valid strings are 'xmlrpcvals', 'phpvals' or 'xml'
- */
- var $return_type = 'xmlrpcvals';
+ * Decides the content of xmlrpcresp objects returned by calls to send()
+ * valid strings are 'xmlrpcvals', 'phpvals' or 'xml'
+ */
+ public $return_type = 'xmlrpcvals';
/**
- * Sent to servers in http headers
- */
- var $user_agent;
+ * Sent to servers in http headers
+ */
+ public $user_agent;
/**
- * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php
- * @param string $server the server name / ip address
- * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used
- * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed
- */
- function xmlrpc_client($path, $server='', $port='', $method='')
+ * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php
+ * @param string $server the server name / ip address
+ * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used
+ * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed
+ */
+ function __construct($path, $server='', $port='', $method='')
{
$xmlrpc = Phpxmlrpc::instance();
}
/**
- * Enables/disables the echoing to screen of the xmlrpc responses received
- * @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
- * @access public
- */
- function setDebug($in)
+ * Enables/disables the echoing to screen of the xmlrpc responses received
+ * @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
+ */
+ public function setDebug($in)
{
$this->debug=$in;
}
/**
- * Add some http BASIC AUTH credentials, used by the client to authenticate
- * @param string $u username
- * @param string $p password
- * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
- * @access public
- */
- function setCredentials($u, $p, $t=1)
+ * Add some http BASIC AUTH credentials, used by the client to authenticate
+ * @param string $u username
+ * @param string $p password
+ * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
+ */
+ public function setCredentials($u, $p, $t=1)
{
$this->username=$u;
$this->password=$p;
}
/**
- * Add a client-side https certificate
- * @param string $cert
- * @param string $certpass
- * @access public
- */
- function setCertificate($cert, $certpass)
+ * Add a client-side https certificate
+ * @param string $cert
+ * @param string $certpass
+ */
+ public function setCertificate($cert, $certpass)
{
$this->cert = $cert;
$this->certpass = $certpass;
}
/**
- * Add a CA certificate to verify server with (see man page about
- * CURLOPT_CAINFO for more details)
- * @param string $cacert certificate file name (or dir holding certificates)
- * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false
- * @access public
- */
- function setCaCertificate($cacert, $is_dir=false)
+ * Add a CA certificate to verify server with (see man page about
+ * CURLOPT_CAINFO for more details)
+ * @param string $cacert certificate file name (or dir holding certificates)
+ * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false
+ */
+ public function setCaCertificate($cacert, $is_dir=false)
{
if ($is_dir)
{
}
/**
- * Set attributes for SSL communication: private SSL key
- * NB: does not work in older php/curl installs
- * Thanks to Daniel Convissor
- * @param string $key The name of a file containing a private SSL key
- * @param string $keypass The secret password needed to use the private SSL key
- * @access public
- */
- function setKey($key, $keypass)
+ * Set attributes for SSL communication: private SSL key
+ * NB: does not work in older php/curl installs
+ * Thanks to Daniel Convissor
+ * @param string $key The name of a file containing a private SSL key
+ * @param string $keypass The secret password needed to use the private SSL key
+ */
+ public function setKey($key, $keypass)
{
$this->key = $key;
$this->keypass = $keypass;
}
/**
- * Set attributes for SSL communication: verify server certificate
- * @param bool $i enable/disable verification of peer certificate
- * @access public
- */
- function setSSLVerifyPeer($i)
+ * Set attributes for SSL communication: verify server certificate
+ * @param bool $i enable/disable verification of peer certificate
+ */
+ public function setSSLVerifyPeer($i)
{
$this->verifypeer = $i;
}
/**
- * Set attributes for SSL communication: verify match of server cert w. hostname
- * @param int $i
- * @access public
- */
- function setSSLVerifyHost($i)
+ * Set attributes for SSL communication: verify match of server cert w. hostname
+ * @param int $i
+ */
+ public function setSSLVerifyHost($i)
{
$this->verifyhost = $i;
}
/**
- * Set proxy info
- * @param string $proxyhost
- * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS
- * @param string $proxyusername Leave blank if proxy has public access
- * @param string $proxypassword Leave blank if proxy has public access
- * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy
- * @access public
- */
- function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1)
+ * Set proxy info
+ * @param string $proxyhost
+ * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS
+ * @param string $proxyusername Leave blank if proxy has public access
+ * @param string $proxypassword Leave blank if proxy has public access
+ * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy
+ */
+ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1)
{
$this->proxy = $proxyhost;
$this->proxyport = $proxyport;
}
/**
- * Enables/disables reception of compressed xmlrpc responses.
- * Note that enabling reception of compressed responses merely adds some standard
- * http headers to xmlrpc requests. It is up to the xmlrpc server to return
- * compressed responses when receiving such requests.
- * @param string $compmethod either 'gzip', 'deflate', 'any' or ''
- * @access public
- */
- function setAcceptedCompression($compmethod)
+ * Enables/disables reception of compressed xmlrpc responses.
+ * Note that enabling reception of compressed responses merely adds some standard
+ * http headers to xmlrpc requests. It is up to the xmlrpc server to return
+ * compressed responses when receiving such requests.
+ * @param string $compmethod either 'gzip', 'deflate', 'any' or ''
+ */
+ public function setAcceptedCompression($compmethod)
{
if ($compmethod == 'any')
$this->accepted_compression = array('gzip', 'deflate');
}
/**
- * Enables/disables http compression of xmlrpc request.
- * Take care when sending compressed requests: servers might not support them
- * (and automatic fallback to uncompressed requests is not yet implemented)
- * @param string $compmethod either 'gzip', 'deflate' or ''
- * @access public
- */
- function setRequestCompression($compmethod)
+ * Enables/disables http compression of xmlrpc request.
+ * Take care when sending compressed requests: servers might not support them
+ * (and automatic fallback to uncompressed requests is not yet implemented)
+ * @param string $compmethod either 'gzip', 'deflate' or ''
+ */
+ public function setRequestCompression($compmethod)
{
$this->request_compression = $compmethod;
}
/**
- * Adds a cookie to list of cookies that will be sent to server.
- * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie:
- * do not do it unless you know what you are doing
- * @param string $name
- * @param string $value
- * @param string $path
- * @param string $domain
- * @param int $port
- * @access public
- *
- * @todo check correctness of urlencoding cookie value (copied from php way of doing it...)
- */
- function setCookie($name, $value='', $path='', $domain='', $port=null)
+ * Adds a cookie to list of cookies that will be sent to server.
+ * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie:
+ * do not do it unless you know what you are doing
+ * @param string $name
+ * @param string $value
+ * @param string $path
+ * @param string $domain
+ * @param int $port
+ *
+ * @todo check correctness of urlencoding cookie value (copied from php way of doing it...)
+ */
+ public function setCookie($name, $value='', $path='', $domain='', $port=null)
{
$this->cookies[$name]['value'] = urlencode($value);
if ($path || $domain || $port)
}
/**
- * Directly set cURL options, for extra flexibility
- * It allows eg. to bind client to a specific IP interface / address
- * @param array $options
- */
+ * Directly set cURL options, for extra flexibility
+ * It allows eg. to bind client to a specific IP interface / address
+ * @param array $options
+ */
function SetCurlOptions( $options )
{
$this->extracurlopts = $options;
}
/**
- * Set user-agent string that will be used by this client instance
- * in http headers sent to the server
- */
+ * Set user-agent string that will be used by this client instance
+ * in http headers sent to the server
+ */
function SetUserAgent( $agentstring )
{
$this->user_agent = $agentstring;
}
/**
- * Send an xmlrpc request
- * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
- * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
- * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used
- * @return xmlrpcresp
- * @access public
- */
- function& send($msg, $timeout=0, $method='')
+ * Send an xmlrpc request
+ * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
+ * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
+ * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used
+ * @return xmlrpcresp
+ */
+ public function& send($msg, $timeout=0, $method='')
{
// if user deos not specify http protocol, use native method of this client
// (i.e. method set during call to constructor)
return $r;
}
- /**
- * @access private
- */
- function &sendPayloadHTTP10($msg, $server, $port, $timeout=0,
+ private function &sendPayloadHTTP10($msg, $server, $port, $timeout=0,
$username='', $password='', $authtype=1, $proxyhost='',
$proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1)
{
}
- /**
- * @access private
- */
- function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='',
+ private function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='',
$password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='',
$proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1,
$keepalive=false, $key='', $keypass='')
}
/**
- * Contributed by Justin Miller <justin@voxel.net>
- * Requires curl to be built into PHP
- * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
- * @access private
- */
- function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',
+ * Contributed by Justin Miller <justin@voxel.net>
+ * Requires curl to be built into PHP
+ * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
+ */
+ private function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',
$password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='',
$proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',
$keepalive=false, $key='', $keypass='')
}
/**
- * Send an array of request messages and return an array of responses.
- * Unless $this->no_multicall has been set to true, it will try first
- * to use one single xmlrpc call to server method system.multicall, and
- * revert to sending many successive calls in case of failure.
- * This failure is also stored in $this->no_multicall for subsequent calls.
- * Unfortunately, there is no server error code universally used to denote
- * the fact that multicall is unsupported, so there is no way to reliably
- * distinguish between that and a temporary failure.
- * If you are sure that server supports multicall and do not want to
- * fallback to using many single calls, set the fourth parameter to FALSE.
- *
- * NB: trying to shoehorn extra functionality into existing syntax has resulted
- * in pretty much convoluted code...
- *
- * @param array $msgs an array of xmlrpcmsg objects
- * @param integer $timeout connection timeout (in seconds)
- * @param string $method the http protocol variant to be used
- * @param boolean fallback When true, upon receiving an error during multicall, multiple single calls will be attempted
- * @return array
- * @access public
- */
- function multicall($msgs, $timeout=0, $method='', $fallback=true)
+ * Send an array of request messages and return an array of responses.
+ * Unless $this->no_multicall has been set to true, it will try first
+ * to use one single xmlrpc call to server method system.multicall, and
+ * revert to sending many successive calls in case of failure.
+ * This failure is also stored in $this->no_multicall for subsequent calls.
+ * Unfortunately, there is no server error code universally used to denote
+ * the fact that multicall is unsupported, so there is no way to reliably
+ * distinguish between that and a temporary failure.
+ * If you are sure that server supports multicall and do not want to
+ * fallback to using many single calls, set the fourth parameter to FALSE.
+ *
+ * NB: trying to shoehorn extra functionality into existing syntax has resulted
+ * in pretty much convoluted code...
+ *
+ * @param array $msgs an array of xmlrpcmsg objects
+ * @param integer $timeout connection timeout (in seconds)
+ * @param string $method the http protocol variant to be used
+ * @param boolean fallback When true, upon receiving an error during multicall, multiple single calls will be attempted
+ * @return array
+ */
+ public function multicall($msgs, $timeout=0, $method='', $fallback=true)
{
$xmlrpc = Phpxmlrpc::instance();
}
/**
- * Attempt to boxcar $msgs via system.multicall.
- * Returns either an array of xmlrpcreponses, an xmlrpc error response
- * or false (when received response does not respect valid multicall syntax)
- * @access private
- */
- function _try_multicall($msgs, $timeout, $method)
+ * Attempt to boxcar $msgs via system.multicall.
+ * Returns either an array of xmlrpcreponses, an xmlrpc error response
+ * or false (when received response does not respect valid multicall syntax)
+ */
+ private function _try_multicall($msgs, $timeout, $method)
{
// Construct multicall message
$calls = array();
<?php
-class xmlrpcmsg
-{
- var $payload;
- var $methodname;
- var $params=array();
- var $debug=0;
- var $content_type = 'text/xml';
+class xmlrpcmsg {
+ /// @todo: does these need to be public?
+ public $payload;
+ public $methodname;
+ public $params=array();
+ public $debug=0;
+ public $content_type = 'text/xml';
/**
- * @param string $meth the name of the method to invoke
- * @param array $pars array of parameters to be passed to the method (xmlrpcval objects)
- */
- function xmlrpcmsg($meth, $pars=0)
+ * @param string $meth the name of the method to invoke
+ * @param array $pars array of parameters to be passed to the method (xmlrpcval objects)
+ */
+ function __construct($meth, $pars=0)
{
$this->methodname=$meth;
if(is_array($pars) && count($pars)>0)
}
}
- /**
- * @access private
- */
- function xml_header($charset_encoding='')
+ private function xml_header($charset_encoding='')
{
if ($charset_encoding != '')
{
}
}
- /**
- * @access private
- */
- function xml_footer()
+ private function xml_footer()
{
return '</methodCall>';
}
- /**
- * @access private
- */
- function kindOf()
+ private function kindOf()
{
return 'msg';
}
- /**
- * @access private
- */
- function createPayload($charset_encoding='')
+ private function createPayload($charset_encoding='')
{
if ($charset_encoding != '')
$this->content_type = 'text/xml; charset=' . $charset_encoding;
}
/**
- * Gets/sets the xmlrpc method to be invoked
- * @param string $meth the method to be set (leave empty not to set it)
- * @return string the method that will be invoked
- * @access public
- */
- function method($meth='')
+ * Gets/sets the xmlrpc method to be invoked
+ * @param string $meth the method to be set (leave empty not to set it)
+ * @return string the method that will be invoked
+ */
+ public function method($meth='')
{
if($meth!='')
{
}
/**
- * Returns xml representation of the message. XML prologue included
- * @param string $charset_encoding
- * @return string the xml representation of the message, xml prologue included
- * @access public
- */
- function serialize($charset_encoding='')
+ * Returns xml representation of the message. XML prologue included
+ * @param string $charset_encoding
+ * @return string the xml representation of the message, xml prologue included
+ */
+ public function serialize($charset_encoding='')
{
$this->createPayload($charset_encoding);
return $this->payload;
}
/**
- * Add a parameter to the list of parameters to be used upon method invocation
- * @param xmlrpcval $par
- * @return boolean false on failure
- * @access public
- */
- function addParam($par)
+ * Add a parameter to the list of parameters to be used upon method invocation
+ * @param xmlrpcval $par
+ * @return boolean false on failure
+ */
+ public function addParam($par)
{
// add check: do not add to self params which are not xmlrpcvals
if(is_object($par) && is_a($par, 'xmlrpcval'))
}
/**
- * Returns the nth parameter in the message. The index zero-based.
- * @param integer $i the index of the parameter to fetch (zero based)
- * @return xmlrpcval the i-th parameter
- * @access public
- */
- function getParam($i) { return $this->params[$i]; }
+ * Returns the nth parameter in the message. The index zero-based.
+ * @param integer $i the index of the parameter to fetch (zero based)
+ * @return xmlrpcval the i-th parameter
+ */
+ public function getParam($i) { return $this->params[$i]; }
/**
- * Returns the number of parameters in the messge.
- * @return integer the number of parameters currently set
- * @access public
- */
- function getNumParams() { return count($this->params); }
+ * Returns the number of parameters in the messge.
+ * @return integer the number of parameters currently set
+ */
+ public function getNumParams() { return count($this->params); }
/**
- * Given an open file handle, read all data available and parse it as axmlrpc response.
- * NB: the file handle is not closed by this function.
- * NNB: might have trouble in rare cases to work on network streams, as we
- * check for a read of 0 bytes instead of feof($fp).
- * But since checking for feof(null) returns false, we would risk an
- * infinite loop in that case, because we cannot trust the caller
- * to give us a valid pointer to an open file...
- * @access public
- * @param resource $fp stream pointer
- * @return xmlrpcresp
- * @todo add 2nd & 3rd param to be passed to ParseResponse() ???
- */
- function &parseResponseFile($fp)
+ * Given an open file handle, read all data available and parse it as axmlrpc response.
+ * NB: the file handle is not closed by this function.
+ * NNB: might have trouble in rare cases to work on network streams, as we
+ * check for a read of 0 bytes instead of feof($fp).
+ * But since checking for feof(null) returns false, we would risk an
+ * infinite loop in that case, because we cannot trust the caller
+ * to give us a valid pointer to an open file...
+ * @param resource $fp stream pointer
+ * @return xmlrpcresp
+ * @todo add 2nd & 3rd param to be passed to ParseResponse() ???
+ */
+ public function &parseResponseFile($fp)
{
$ipd='';
while($data=fread($fp, 32768))
}
/**
- * Parses HTTP headers and separates them from data.
- * @access private
- */
- function &parseResponseHeaders(&$data, $headers_processed=false)
+ * Parses HTTP headers and separates them from data.
+ */
+ private function &parseResponseHeaders(&$data, $headers_processed=false)
{
$xmlrpc = Phpxmlrpc::instance();
// Support "web-proxy-tunelling" connections for https through proxies
}
/**
- * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object.
- * @param string $data the xmlrpc response, eventually including http headers
- * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding
- * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'
- * @return xmlrpcresp
- * @access public
- */
- function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals')
+ * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object.
+ * @param string $data the xmlrpc response, eventually including http headers
+ * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding
+ * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'
+ * @return xmlrpcresp
+ */
+ public function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals')
{
$xmlrpc = Phpxmlrpc::instance();
<?php
-class xmlrpcresp
-{
- var $val = 0;
- var $valtyp;
- var $errno = 0;
- var $errstr = '';
- var $payload;
- var $hdrs = array();
- var $_cookies = array();
- var $content_type = 'text/xml';
- var $raw_data = '';
+class xmlrpcresp {
+ /// @todo: does these need to be public?
+ public $val = 0;
+ public $valtyp;
+ public $errno = 0;
+ public $errstr = '';
+ public $payload;
+ public $hdrs = array();
+ public $_cookies = array();
+ public $content_type = 'text/xml';
+ public $raw_data = '';
/**
- * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string)
- * @param integer $fcode set it to anything but 0 to create an error response
- * @param string $fstr the error string, in case of an error response
- * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml'
- *
- * @todo add check that $val / $fcode / $fstr is of correct type???
- * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain
- * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called...
- */
- function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='')
+ * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string)
+ * @param integer $fcode set it to anything but 0 to create an error response
+ * @param string $fstr the error string, in case of an error response
+ * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml'
+ *
+ * @todo add check that $val / $fcode / $fstr is of correct type???
+ * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain
+ * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called...
+ */
+ function __construct($val, $fcode = 0, $fstr = '', $valtyp='')
{
if($fcode != 0)
{
}
/**
- * Returns the error code of the response.
- * @return integer the error code of this response (0 for not-error responses)
- * @access public
- */
- function faultCode()
+ * Returns the error code of the response.
+ * @return integer the error code of this response (0 for not-error responses)
+ */
+ public function faultCode()
{
return $this->errno;
}
/**
- * Returns the error code of the response.
- * @return string the error string of this response ('' for not-error responses)
- * @access public
- */
- function faultString()
+ * Returns the error code of the response.
+ * @return string the error string of this response ('' for not-error responses)
+ */
+ public function faultString()
{
return $this->errstr;
}
/**
- * Returns the value received by the server.
- * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects
- * @access public
- */
- function value()
+ * Returns the value received by the server.
+ * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects
+ */
+ public function value()
{
return $this->val;
}
/**
- * Returns an array with the cookies received from the server.
- * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...)
- * with attributes being e.g. 'expires', 'path', domain'.
- * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past)
- * are still present in the array. It is up to the user-defined code to decide
- * how to use the received cookies, and whether they have to be sent back with the next
- * request to the server (using xmlrpc_client::setCookie) or not
- * @return array array of cookies received from the server
- * @access public
- */
- function cookies()
+ * Returns an array with the cookies received from the server.
+ * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...)
+ * with attributes being e.g. 'expires', 'path', domain'.
+ * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past)
+ * are still present in the array. It is up to the user-defined code to decide
+ * how to use the received cookies, and whether they have to be sent back with the next
+ * request to the server (using xmlrpc_client::setCookie) or not
+ * @return array array of cookies received from the server
+ */
+ public function cookies()
{
return $this->_cookies;
}
/**
- * Returns xml representation of the response. XML prologue not included
- * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
- * @return string the xml representation of the response
- * @access public
- */
- function serialize($charset_encoding='')
+ * Returns xml representation of the response. XML prologue not included
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
+ * @return string the xml representation of the response
+ */
+ public function serialize($charset_encoding='')
{
$xmlrpc = Phpxmlrpc::instance();
<?php
-class xmlrpcval
-{
- var $me=array();
- var $mytype=0;
- var $_php_class=null;
+class xmlrpcval {
+
+ /// @todo: does these need to be public?
+ public $me=array();
+ public $mytype=0;
+ public $_php_class=null;
/**
- * @param mixed $val
- * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed
- */
- function xmlrpcval($val=-1, $type='')
- {
+ * @param mixed $val
+ * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed
+ */
+ function __construct($val=-1, $type='') {
/// @todo: optimization creep - do not call addXX, do it all inline.
/// downside: booleans will not be coerced anymore
if($val!==-1 || $type!='')
}
/**
- * Add a single php value to an (unitialized) xmlrpcval
- * @param mixed $val
- * @param string $type
- * @return int 1 or 0 on failure
- */
+ * Add a single php value to an (unitialized) xmlrpcval
+ * @param mixed $val
+ * @param string $type
+ * @return int 1 or 0 on failure
+ */
function addScalar($val, $type='string')
{
$xmlrpc = Phpxmlrpc::instance();
}
/**
- * Add an array of xmlrpcval objects to an xmlrpcval
- * @param array $vals
- * @return int 1 or 0 on failure
- * @access public
- *
- * @todo add some checking for $vals to be an array of xmlrpcvals?
- */
- function addArray($vals)
+ * Add an array of xmlrpcval objects to an xmlrpcval
+ * @param array $vals
+ * @return int 1 or 0 on failure
+ *
+ * @todo add some checking for $vals to be an array of xmlrpcvals?
+ */
+ public function addArray($vals)
{
$xmlrpc = Phpxmlrpc::instance();
if($this->mytype==0)
}
/**
- * Add an array of named xmlrpcval objects to an xmlrpcval
- * @param array $vals
- * @return int 1 or 0 on failure
- * @access public
- *
- * @todo add some checking for $vals to be an array?
- */
- function addStruct($vals)
+ * Add an array of named xmlrpcval objects to an xmlrpcval
+ * @param array $vals
+ * @return int 1 or 0 on failure
+ *
+ * @todo add some checking for $vals to be an array?
+ */
+ public function addStruct($vals)
{
$xmlrpc = Phpxmlrpc::instance();
}
}
- // poor man's version of print_r ???
- // DEPRECATED!
- function dump($ar)
- {
- foreach($ar as $key => $val)
- {
- echo "$key => $val<br />";
- if($key == 'array')
- {
- while(list($key2, $val2) = each($val))
- {
- echo "-- $key2 => $val2<br />";
- }
- }
- }
- }
-
/**
- * Returns a string containing "struct", "array" or "scalar" describing the base type of the value
- * @return string
- * @access public
- */
- function kindOf()
+ * Returns a string containing "struct", "array" or "scalar" describing the base type of the value
+ * @return string
+ */
+ public function kindOf()
{
switch($this->mytype)
{
}
}
- /**
- * @access private
- */
- function serializedata($typ, $val, $charset_encoding='')
+ private function serializedata($typ, $val, $charset_encoding='')
{
$xmlrpc = Phpxmlrpc::instance();
$rs='';
}
/**
- * Returns xml representation of the value. XML prologue not included
- * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
- * @return string
- * @access public
- */
- function serialize($charset_encoding='')
+ * Returns xml representation of the value. XML prologue not included
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
+ * @return string
+ */
+ public function serialize($charset_encoding='')
{
// add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
}
/**
- * Checks whether a struct member with a given name is present.
- * Works only on xmlrpcvals of type struct.
- * @param string $m the name of the struct member to be looked up
- * @return boolean
- * @access public
- */
- function structmemexists($m)
+ * Checks whether a struct member with a given name is present.
+ * Works only on xmlrpcvals of type struct.
+ * @param string $m the name of the struct member to be looked up
+ * @return boolean
+ */
+ public function structmemexists($m)
{
return array_key_exists($m, $this->me['struct']);
}
/**
- * Returns the value of a given struct member (an xmlrpcval object in itself).
- * Will raise a php warning if struct member of given name does not exist
- * @param string $m the name of the struct member to be looked up
- * @return xmlrpcval
- * @access public
- */
- function structmem($m)
+ * Returns the value of a given struct member (an xmlrpcval object in itself).
+ * Will raise a php warning if struct member of given name does not exist
+ * @param string $m the name of the struct member to be looked up
+ * @return xmlrpcval
+ */
+ public function structmem($m)
{
return $this->me['struct'][$m];
}
/**
- * Reset internal pointer for xmlrpcvals of type struct.
- * @access public
- */
- function structreset()
+ * Reset internal pointer for xmlrpcvals of type struct.
+ */
+ public function structreset()
{
reset($this->me['struct']);
}
/**
- * Return next member element for xmlrpcvals of type struct.
- * @return xmlrpcval
- * @access public
- */
- function structeach()
+ * Return next member element for xmlrpcvals of type struct.
+ * @return xmlrpcval
+ */
+ public function structeach()
{
return each($this->me['struct']);
}
}
/**
- * Returns the value of a scalar xmlrpcval
- * @return mixed
- * @access public
- */
- function scalarval()
+ * Returns the value of a scalar xmlrpcval
+ * @return mixed
+ */
+ public function scalarval()
{
reset($this->me);
list(,$b)=each($this->me);
}
/**
- * Returns the type of the xmlrpcval.
- * For integers, 'int' is always returned in place of 'i4'
- * @return string
- * @access public
- */
- function scalartyp()
+ * Returns the type of the xmlrpcval.
+ * For integers, 'int' is always returned in place of 'i4'
+ * @return string
+ */
+ public function scalartyp()
{
$xmlrpc = Phpxmlrpc::instance();
}
/**
- * Returns the m-th member of an xmlrpcval of struct type
- * @param integer $m the index of the value to be retrieved (zero based)
- * @return xmlrpcval
- * @access public
- */
- function arraymem($m)
+ * Returns the m-th member of an xmlrpcval of struct type
+ * @param integer $m the index of the value to be retrieved (zero based)
+ * @return xmlrpcval
+ */
+ public function arraymem($m)
{
return $this->me['array'][$m];
}
/**
- * Returns the number of members in an xmlrpcval of array type
- * @return integer
- * @access public
- */
- function arraysize()
+ * Returns the number of members in an xmlrpcval of array type
+ * @return integer
+ */
+ public function arraysize()
{
return count($this->me['array']);
}
/**
- * Returns the number of members in an xmlrpcval of struct type
- * @return integer
- * @access public
- */
- function structsize()
+ * Returns the number of members in an xmlrpcval of struct type
+ * @return integer
+ */
+ public function structsize()
{
return count($this->me['struct']);
}