-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:novaksolutions/infusionsoft-php-sdk
- Loading branch information
Showing
1 changed file
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
// by Edd Dumbill (C) 1999-2002 | ||
// <[email protected]> | ||
// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $ | ||
|
||
// Copyright (c) 1999,2000,2002 Edd Dumbill. | ||
// All rights reserved. | ||
|
@@ -35,9 +34,6 @@ | |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
// OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
$GLOBALS['xmlrpcName']='Infusionsoft PHP SDK 1.28.x'; | ||
$GLOBALS['xmlrpcVersion']='3.0.0.beta'; | ||
|
||
if(!function_exists('xml_parser_create')) | ||
{ | ||
// For PHP 4 onward, XML functionality is always compiled-in on windows: | ||
|
@@ -211,6 +207,9 @@ | |
// as if having been coded with this | ||
$GLOBALS['xmlrpc_internalencoding']='UTF-8'; | ||
|
||
$GLOBALS['xmlrpcName']='XML-RPC for PHP'; | ||
$GLOBALS['xmlrpcVersion']='3.0.0.beta'; | ||
|
||
// let user errors start at 800 | ||
$GLOBALS['xmlrpcerruser']=800; | ||
// let XML parse errors start at 100 | ||
|
@@ -226,6 +225,7 @@ | |
|
||
// set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/> | ||
$GLOBALS['xmlrpc_null_apache_encoding']=false; | ||
$GLOBALS['xmlrpc_null_apache_encoding_ns']='http://ws.apache.org/xmlrpc/namespaces/extensions'; | ||
|
||
// used to store state during parsing | ||
// quick explanation of components: | ||
|
@@ -858,7 +858,7 @@ | |
* http://curl.haxx.se/docs/faq.html#7.3) | ||
*/ | ||
var $xmlrpc_curl_handle = null; | ||
/// Wheter to use persistent connections for http 1.1 and https | ||
/// Whether to use persistent connections for http 1.1 and https | ||
var $keepalive = false; | ||
/// Charset encodings that can be decoded without problems by the client | ||
var $accepted_charset_encodings = array(); | ||
|
@@ -952,7 +952,7 @@ | |
|
||
/** | ||
* Enables/disables the echoing to screen of the xmlrpc responses received | ||
* @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) | ||
* @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) | ||
* @access public | ||
*/ | ||
function setDebug($in) | ||
|
@@ -988,7 +988,7 @@ | |
|
||
/** | ||
* Add a CA certificate to verify server with (see man page about | ||
* CURLOPT_CAINFO for more details | ||
* 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 | ||
|
@@ -1070,7 +1070,10 @@ | |
if ($compmethod == 'any') | ||
$this->accepted_compression = array('gzip', 'deflate'); | ||
else | ||
$this->accepted_compression = array($compmethod); | ||
if ($compmethod == false ) | ||
$this->accepted_compression = array(); | ||
else | ||
$this->accepted_compression = array($compmethod); | ||
} | ||
|
||
/** | ||
|
@@ -1117,7 +1120,7 @@ | |
/** | ||
* Directly set cURL options, for extra flexibility | ||
* It allows eg. to bind client to a specific IP interface / address | ||
* @param $options array | ||
* @param array $options | ||
*/ | ||
function SetCurlOptions( $options ) | ||
{ | ||
|
@@ -1350,9 +1353,12 @@ | |
$cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; | ||
} | ||
|
||
// omit port if 80 | ||
$port = ($port == 80) ? '' : (':' . $port); | ||
|
||
$op= 'POST ' . $uri. " HTTP/1.0\r\n" . | ||
'User-Agent: ' . $this->user_agent . "\r\n" . | ||
'Host: '. $server . ':' . $port . "\r\n" . | ||
'Host: '. $server . $port . "\r\n" . | ||
$credentials . | ||
$proxy_credentials . | ||
$accepted_encoding . | ||
|
@@ -1401,11 +1407,11 @@ | |
} | ||
else | ||
{ | ||
// reset errno and errstr on succesful socket connection | ||
// reset errno and errstr on successful socket connection | ||
$this->errstr = ''; | ||
} | ||
// G. Giunta 2005/10/24: close socket before parsing. | ||
// should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) | ||
// should yield slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) | ||
$ipd=''; | ||
do | ||
{ | ||
|
@@ -1543,7 +1549,6 @@ | |
// return the header too | ||
curl_setopt($curl, CURLOPT_HEADER, 1); | ||
|
||
// will only work with PHP >= 5.0 | ||
// NB: if we set an empty string, CURL will add http header indicating | ||
// ALL methods it is supporting. This is possibly a better option than | ||
// letting the user tell what curl can / cannot do... | ||
|
@@ -1675,7 +1680,14 @@ | |
{ | ||
print "<PRE>\n---CURL INFO---\n"; | ||
foreach(curl_getinfo($curl) as $name => $val) | ||
print $name . ': ' . htmlentities($val). "\n"; | ||
{ | ||
if (is_array($val)) | ||
{ | ||
$val = implode("\n", $val); | ||
} | ||
print $name . ': ' . htmlentities($val) . "\n"; | ||
} | ||
|
||
print "---END---\n</PRE>"; | ||
} | ||
|
||
|
@@ -1696,6 +1708,12 @@ | |
curl_close($curl); | ||
} | ||
$resp =& $msg->parseResponse($result, true, $this->return_type); | ||
// if we got back a 302, we can not reuse the curl handle for later calls | ||
if($resp->faultCode() == $GLOBALS['xmlrpcerr']['http_error'] && $keepalive) | ||
{ | ||
curl_close($curl); | ||
$this->xmlrpc_curl_handle = null; | ||
} | ||
} | ||
return $resp; | ||
} | ||
|
@@ -1718,7 +1736,7 @@ | |
* @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 receiveing an error during multicall, multiple single calls will be attempted | ||
* @param boolean fallback When true, upon receiving an error during multicall, multiple single calls will be attempted | ||
* @return array | ||
* @access public | ||
*/ | ||
|
@@ -2025,7 +2043,7 @@ | |
* 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 wheter they have to be sent back with the next | ||
* 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 | ||
|
@@ -2047,7 +2065,14 @@ | |
$this->content_type = 'text/xml; charset=' . $charset_encoding; | ||
else | ||
$this->content_type = 'text/xml'; | ||
if ($GLOBALS['xmlrpc_null_apache_encoding']) | ||
{ | ||
$result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n"; | ||
} | ||
else | ||
{ | ||
$result = "<methodResponse>\n"; | ||
} | ||
if($this->errno) | ||
{ | ||
// G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients | ||
|
@@ -2097,7 +2122,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
|
||
/** | ||
* @param string $meth the name of the method to invoke | ||
* @param array $pars array of parameters to be paased to the method (xmlrpcval objects) | ||
* @param array $pars array of parameters to be passed to the method (xmlrpcval objects) | ||
*/ | ||
function xmlrpcmsg($meth, $pars=0) | ||
{ | ||
|
@@ -2181,6 +2206,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
|
||
/** | ||
* 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 | ||
*/ | ||
|
@@ -2234,6 +2260,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
* 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() ??? | ||
*/ | ||
|
@@ -3077,7 +3104,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
} | ||
|
||
/** | ||
* Checks wheter a struct member with a given name is present. | ||
* 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 | ||
|
@@ -3679,9 +3706,10 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
* we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers, | ||
* which will be most probably using UTF-8 anyway... | ||
* | ||
* @param string $httpheaders the http Content-type header | ||
* @param string $httpheader the http Content-type header | ||
* @param string $xmlchunk xml content buffer | ||
* @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled) | ||
* @return string | ||
* | ||
* @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!! | ||
*/ | ||
|
@@ -3774,6 +3802,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha | |
* if it is a valid subset of any encoding in the list | ||
* @param string $encoding charset to be tested | ||
* @param mixed $validlist comma separated list of valid charsets (or array of charsets) | ||
* @return bool | ||
*/ | ||
function is_valid_charset($encoding, $validlist) | ||
{ | ||
|