From: Thierry Parmentelat
Date: Thu, 6 Jul 2017 13:08:07 +0000 (+0200)
Subject: Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
X-Git-Tag: plcapi-5.4-0~3
X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=21d187714285d9818fd94509b015ba069facb7ef;hp=9bd41316bc9541bbedfe45377089d4e4927129b1
Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
git-subtree-dir: php/phpxmlrpc
git-subtree-mainline: 9bd41316bc9541bbedfe45377089d4e4927129b1
git-subtree-split: cd5dbb4a511e7a616a61187a5de1a611a9748cbd
---
diff --git a/php/phpxmlrpc/.gitignore b/php/phpxmlrpc/.gitignore
new file mode 100644
index 0000000..1305331
--- /dev/null
+++ b/php/phpxmlrpc/.gitignore
@@ -0,0 +1,6 @@
+/.idea
+composer.phar
+composer.lock
+/vendor/*
+/tests/coverage/*
+/build/*
diff --git a/php/phpxmlrpc/.travis.yml b/php/phpxmlrpc/.travis.yml
new file mode 100644
index 0000000..38878b6
--- /dev/null
+++ b/php/phpxmlrpc/.travis.yml
@@ -0,0 +1,53 @@
+language: php
+
+php:
+ - 5.3
+ - 5.4
+ - 5.5
+ - 5.6
+ - 7.0
+ - 7.1
+ # hhvm is not available any more on default travis images
+ #- hhvm
+
+before_install:
+ # This is mandatory or the 'apt-get install' calls following will fail
+ - sudo apt-get update -qq
+ - sudo apt-get install -y apache2 libapache2-mod-fastcgi
+ - sudo apt-get install -y privoxy
+
+install:
+ - composer self-update && composer install
+
+before_script:
+ # Disable xdebug for speed.
+ # NB: this should NOT be done for hhvm and php 7.0.
+ # Also we use the php 5.6 run to generate code coverage reports, and we need xdebug for that
+ - if [ "$TRAVIS_PHP_VERSION" != "hhvm" -a "$TRAVIS_PHP_VERSION" != "7.0" -a "$TRAVIS_PHP_VERSION" != "5.6" ]; then phpenv config-rm xdebug.ini; fi
+
+ # Set up Apache and Privoxy instances inside the Travis VM and use them for testing against
+ - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then ./tests/ci/travis/setup_php_fpm.sh; ./tests/ci/travis/setup_apache.sh; fi
+ - if [ "$TRAVIS_PHP_VERSION" = "hhvm" ]; then ./tests/ci/travis/setup_hhvm.sh; ./tests/ci/travis/setup_apache_hhvm.sh; fi
+ - ./tests/ci/travis/setup_privoxy.sh
+
+ # output what version of phpunit we got going
+ - vendor/bin/phpunit --version
+
+script:
+ # Travis currently compiles PHP with an oldish cURL/GnuTLS combination;
+ # to make the tests pass when Apache has a bogus SSL cert whe need the full set of options below
+ vendor/bin/phpunit --coverage-clover=coverage.clover tests LOCALSERVER=localhost URI=/demo/server/server.php HTTPSSERVER=localhost HTTPSURI=/demo/server/server.php PROXY=localhost:8080 HTTPSVERIFYHOST=0 HTTPSIGNOREPEER=1 SSLVERSION=3 DEBUG=1
+
+after_failure:
+ # Save as much info as we can to help developers
+ - cat apache_error.log
+ - cat apache_access.log
+ #- cat /var/log/hhvm/error.log
+ #- if [ "$TRAVIS_PHP_VERSION" = "hhvm" ]; then php -i; fi
+
+after_script:
+ # Upload code-coverage to Scrutinizer
+ - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
+ - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
+ # Upload code-coverage CodeClimate
+ - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then CODECLIMATE_REPO_TOKEN=7fa6ee01e345090e059e5e42f3bfbcc8692feb8340396382dd76390a3019ac13 ./vendor/bin/test-reporter --coverage-report=coverage.clover; fi
diff --git a/php/phpxmlrpc/ChangeLog b/php/phpxmlrpc/ChangeLog
new file mode 100644
index 0000000..e032f79
--- /dev/null
+++ b/php/phpxmlrpc/ChangeLog
@@ -0,0 +1,1623 @@
+NB: All recent commits are available online.
+This file will not be updated further.
+See https://github.com/gggeek/phpxmlrpc/commits/master
+
+2014-05-26 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * removed bundled phpunit
+ * converted all tabs to spaces in php files and removed closing tags
+
+2014-05-12 - Samu Voutilainen (smar@smar.fi)
+
+ * removed obsolete xml.so open; dl() is deprecated and removed from 5.3.0
+ * removed deprecated xmlEntities
+ * removed deprecated xmlrpc_backslash
+ * converted $GLOBALS to internal class. This makes testing much easier and should be more flexible regarding other projects
+ * changed verifyhost from 1 to 2. This makes modern php versions work properly.
+ * split off each class in its own file
+
+2014-02-03 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * bumped up requirements to php 5.1.0
+
+2014-01-10 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: when using curl and keepalive, reset curl handle if we did not get back an http 200 response (eg a 302)
+
+ * testsuite.php, parse_args.php: update testsuite
+
+ * debugger/controller.php: change default path to javascript debugger
+
+2010-05-23 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: omit port on http 'Host' header if it is 80;
+ add a namespace declaration in response if ex:nil is in use
+
+2010-04-12 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * testsuite.php, parse_args.php: testsuite allows interrogating https servers ignoring their certs
+
+ * xmlrpc.inc: method setAcceptedCompression was failing to disable reception
+ of compressed responses if the client supported them (triggering a bug with
+ https and php < 5.3 on windows); remove a php warning that could be
+ generated when using debug=2 in a client connecting to an https
+ server
+
+2010-04-11 - G. Giunta (giunta.gaetano@gmail.com) thanks amoe
+
+ * fixed: bad variables in "make install" make target
+
+2009-11-11 - G. Giunta (giunta.gaetano@gmail.com) thanks Ikiro Watanabe
+
+ * added INSTALL file
+
+2009-09-05 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpcs.inc, xmlrpcs.inc: remove code that was left for compatibility
+ with php 4; use __METHOD__ constant for error messages instead of hardcoded
+ values
+
+ * xmlrpcs.inc: catch exceptions thrown during execution of invoked methods;
+ check for $_SERVER having been disabled via php.ini and log an error if so
+
+ * server.php, testsuite.php: add a new test and server method for exception
+ catching in the server
+
+ * xmlrpc.inc: added new method SetUserAgent to client to allow having different
+ user-agent http headers
+
+ * tagged and released as 3.0.0 beta
+
+2009-08-05 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc_wrappers.inc: improve compatibility with php 5.0 when registering
+ class/object methods
+
+2009-08-02 - G. Giunta (giunta.gaetano@gmail.com) thanks Laurens
+
+ * xmlrpcs.inc: add a new member var in server class to allow fine-tuning
+ of the encoding of returned values when the server is in 'phpvals' mode;
+ allow servers in 'xmlrpcvals' mode to also register plain php functions by
+ defining them in the dispatch map with an added option:
+ 'parameters_type' => 'phpvals' (feature request #2806628)
+
+ * xmlrpc.inc: added new method xmrlpc_client::SetCurlOptions($array) to
+ allow extra flexibility in tweaking http config, such as explicitly
+ binding to an ip address (feature request #2787468); fix bad encoding if
+ same object is encoded twice using php_xmlrpc_encode; removed some by-ref
+ assignments and declarations
+
+2009-07-31 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: add support for dateTime objects in both in php_xmlrpc_encode
+ and as parameter for constructor of xmlrpcvals; add support for timestamps
+ as parameter for constructor of xmlrpcvals; add option 'dates_as_objects' to
+ php_xmlrpc_decode to return dateTime objects for xmlrpc datetimes
+
+ * benchmark.php, xmlrpc_wrappers.inc: remove usage of split(), deprecated in
+ php 5.3
+
+ * benchmark.php: fixed url of server page used for testing; improved
+ verification of correspondence of test results; added more variants for
+ http options comparison
+
+ * verify_compat.php: check for php version 5 for client side too
+
+ * makefile: remove from build the compat directory
+
+2009-07-26 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * server.php: remove usage of ereg*(), deprecated in php 5.3
+
+2009-07-16 - G. Giunta (giunta.gaetano@gmail.com) thanks Jean-Jacques Sarton
+
+ * xmlrpc.inc: add support for the from the apache library, both
+ in input and output (feature request #...)
+
+ * xmlrpc.inc, testsuite.php: remove usage of split(), deprecated in php 5.3
+
+ * testsuite.php: flush better results with output_buffering on
+
+ * server: php: avoid one warning about static function calls
+
+2009-07-02 - G. Giunta (giunta.gaetano@gmail.com) thanks Heiko Stuebner
+
+ * xmlrpc.inc: fix: when checking the parameters against the signatures xmlrpc
+ checks for "array" but PHP returns "Array" resulting in a not matches signature
+
+2009-05-07 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * replace all usage of '= & new' with '= new', as this is deprecated in php 5
+ and has been shown to cause problems too
+
+2009-05-06 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * create php4 branch, rename trunk to 3.0.0beta - it will be the php5-only version
+
+ * xmlrpc.inc: removed test for php version and inclusion of compat patches for really
+ really old versions of php 4
+
+2009-03-16 - G. Giunta (giunta.gaetano@gmail.com) thanks Tommaso Trani
+
+ * move from CVS to SVN on sf.net; file layout now is the same as in packaged lib
+
+ * xmlrpc.inc: fix php warning when receiving 'false' in a bool value
+
+ * Makefile, doc/Makefile: alter to follow new file layout
+
+ * tagged and released as 2.2.2
+
+2009-02-03 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * debugger/action.php: improve code robustness when parsing system.listmethods
+ and system.describemethods call
+
+ * xmlrpc.inc: format floating point values using the correct decimal separator
+ even when php locale is set to one that uses comma (bug #2517579);
+ use feof() to test if socket connections are to be closed instead of the
+ number of bytes read (bug #2556209)
+
+2008-10-29 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpcs.inc: allow add_to_map server method to add docs for single params, too
+
+2008-09-20 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc_wrappers.inc: added the possibility to wrap for exposure as xmlrpc
+ methods plain php class methods, object methods and even whole classes
+
+ * testsuite.php, server.php: added test cases for the new code
+
+2008-09-07 - G. Giunta (giunta.gaetano@gmail.com) thanks Bruno Zanetti Melotti
+
+ * xmlrpc.inc: be more tolerant in detection of charset in http headers (fix for bug #2058158)
+
+2008-04-05 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: fix encoding of UTF8 chars outside of the BMP
+
+ * xmlrpcs.inc: fix detection of zlib.output_compression (thanks xbert)
+
+2008-03-06 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * tagged and released as 2.2.1
+
+ * Makefile: improve usage on windows xp despite cmd's broken mkdir
+
+2007-10-26 - G. Giunta (giunta.gaetano@gmail.com) thanks sajo_raftman
+
+ * xmlrpc.inc: remove one warning in xmlrpc_client creator
+
+2007-10-26 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: improve support for windows cp1252 character set (still
+ commented in the code)
+
+2007-09-05 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc, xmlrps.inc: do not try to set invalid charsets as output for
+ xml parser, even if user set them up for internal_encoding (helps encoding
+ to exotic charsets, while decoding to UTF8)
+
+2007-09-05 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: fix parsing of '1e+1' as valid float
+
+2007-09-01 - G. Giunta (giunta.gaetano@gmail.com), thanks Frederic Lecointre
+
+ * xmlrpcs.inc: allow errorlevel 3 to work when prev. error handler was a static method
+
+ * testsuite.php: fix test on setCookie()
+
+2007-08-31 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: minor fix in cookie parsing
+
+2007-07-31 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: Fix usage of client::setcookie() for multiple cookies in non-ssl mode
+
+2007-07-26 - G. Giunta (giunta.gaetano@gmail.com) thanks Mark Olive
+
+ * xmlrpc.inc: Fix for bug # 1756274 (usage of cookies in ssl mode)
+
+2007-04-28 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: give more detailed curl information when DEBUG = 2; fix handling
+ of case where curl w. keepalive is used and one connection of many fails
+
+ * testsuite improvements: add one testcase; give feedbcak while tests are
+ running
+
+2007-04-01 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * doc/makefile, doc/custom.fo.xsl: improve pdf rendering of php source code
+
+ * makefile: recover version number from source instead of having it hardcoded
+
+2007-03-10 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * doc/makefile, doc/convert.php, doc/*.xsl: created customizations xslt to
+ produce a documentation more in line with the php manual, esp. with regards
+ to functions synopsis; added jellyfish book cover as local resource and a
+ screenshot of the debugger too; various updates to the manual source; added
+ a php script to highlight examples inside html docs
+
+2007-03-09 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * debugger/action.php: css tweak for IE
+
+ * added phpunit license file in the phpunit directory
+
+ * added link to license (on sf.net site) to many files
+
+2007-03-04 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * Makefile, doc/makefile: assorted improvements
+
+2007-03-03 - G. Giunta (giunta.gaetano@gmail.com)
+
+ * xmlrpc.inc: micro-optimization in declaration of global vars xmlrpcerr, xmlrpcstr
+
+2007-02-25 Gaetano Giunta
+
+ * removed a couple of warnings emitted in testsuite.php
+
+ * doc/makefile: added command for invocation of xxe to generate docs
+
+ * better rendering of docs in xml+css format for function prototypes
+
+ * updated documentation
+
+ * tagged and released as 2.2
+
+2007-02-22 Gaetano Giunta
+
+ * debugger: workaround for case of magic_quotes_gpc being set (properly
+ unescape user input); fix case of user not setting msg id in jsonrpc case
+ when executing a remote method; allow strings, false, true and null as msg id
+
+2007-02-13 Gaetano Giunta
+
+ * testsuite.php: added one test for automatic encoding/decoding case
+
+2007-02-05 Gaetano Giunta
+
+ * xmlrpc.inc: slightly faster encoding of UTF8 data to ascii
+
+2007-01-11 Gaetano Giunta
+
+ * xmlrpc.inc: when calling client::multicall() with an unspecified http version,
+ use the client default rather than the fixed 'http 1.0'
+
+2006-09-17 Gaetano Giunta
+
+ * xmlrpc.inc, xmlrpcs.inc, testsuite.php: added support for and
+ system.getCapabilities, and one more testcase to go with it
+
+2006-09-05 Gaetano Giunta
+
+ * xmlrpc.inc: fix support for https through proxies; client parses debug
+ messages sent by client even for compressed responses;
+
+ * testsuite.php, parse_args.php: added 3 test cases for proxy connections
+
+2006-09-01 Gaetano Giunta
+
+ xmlrpc_wrappers.inc: add two more options in wrap_xmlrpc_method and fix
+ typo to allow obj encoding
+
+2006-08-28 Gaetano Giunta
+
+ * xmlrpc_wrappers.inc: more options added to wrap_php_function and
+ wrap_xmlrpc_method
+
+ * xmlrpc.inc: pave the way to support for
+
+ * doc/xmlrpc_php.xml documentation updated
+
+ * tagged and released as 2.1
+
+2006-08-25 Gaetano Giunta
+
+ * xmlrpc.inc: stricter parsing of incoming messages: detect two DATA elements
+ inside an ARRAY, a STRUCT or SCALAR inside an already filled VALUE
+
+ * testsuite.php: added two testcases to check for the above cases
+
+2006-08-24 Gaetano Giunta
+
+ * xmlrpc.inc: more code optimization in xmlrpcval::serialize() and
+ php_xmlrpc_encode(); fixed bug where struct elements with non-ascii chars
+ in their name would not be properly encoded
+
+ * testsuite.php: added a testcase for the new bug
+
+2006-08-23 Gaetano Giunta
+
+ * remove old code left in comments across many files; many more javadoc
+ comments added
+
+ * xmlrpc.inc: a bit of code optimization: reorder switch() statements of
+ xml parsing element handlers; inline code for xmlrpcval() - this breaks
+ new xmlrpcval('true') and changes error msgs on new xmlrpcval($x, 'invalid_type')
+
+ * testsuite.php: change according to above
+
+ * benchmark.php: basic support for xdebug 2 profiling
+
+2006-08-22 Gaetano Giunta
+
+ * xmlrpc.inc: addscalar() and addstruct() where not returning 1 when adding
+ data to an already formed value
+
+2006-08-21 Gaetano Giunta
+
+ * xmlrpcs.inc, xmlrpc.inc: added support for emulating the xmlrpc-extension
+ API (the full emulation layer is part of the extras package);
+ fix support for the HTTP 'deflate' encoding
+
+ * xmlrpc.inc: better support for http compression with and without CURL;
+ a minor decoding speedup; added a new function: php_xmlrpc_decode_xml(),
+ that will convert into the appropriate object the xml representation of
+ either a request, response or a single value; log reception of invalid
+ datetime values
+
+ * xmlrpcs.inc: add a new parameter and return type to server->service();
+ let server->add_to_map() accept method definitions without parameter types
+
+ * xmlrpc_wrappers.inc: more logging of errors; wrap_php_functions now takes
+ more options; better support for jsonrpc; escape quote chars when wrapping
+ remothe servers / remote methods
+
+ * added cvs Id tag to files that missed it; speling fixes; updated NEWS files
+
+2006-08-07 Gaetano Giunta
+
+ * assorted fixes to make the suite more compatible with php 4.0.5 and 5.x
+
+2006-07-02 Gaetano Giunta
+
+ * xmlrpc_warppers.inc: added new function to wrap entire remote server into
+ a local php class; changed default calling synopsis of wrap_remote_method,
+ to ease passing multiple options at a time (but old syntax still works!)
+
+ * updated makefile, debugger/action.php in accord with the above
+
+2006-06-30 Gaetano Giunta
+
+ * added to debugger capability to generate json-rpc code stubs
+
+ * added to debugger capability to load and launch self correctly if
+ controller.php is called directly from outside processes (single url access)
+
+2006-06-26 Gaetano Giunta
+
+ * moved wrap_php_functions and wrap_xmlrpc_method into a file of their own.
+ This will let us add further stub functionality without the base lib growing too much.
+ All of the files that reference this functionality have been modified accordingly.
+
+ * made wrap_xmlrpc_method generate better code (with php type juggling), and
+ some phpdoc for the generated function, too
+
+ * added to debugger an option to produce for the user the generated php code
+ for wrapping a call to a remote method into a php function
+
+2006-06-22 Gaetano Giunta
+
+ * xmlrpcs.inc: added description of parameters for system.xxx methods (useful with
+ html-self-documenting servers);
+ server->service() now returns response object, in case user has need for it...
+
+ * xmlrpc.inc: save full response payload into xmlrpcresp obj for better debugging
+
+2006-06-15 Gaetano Giunta
+
+ * verify_compat.php: more tests
+
+2006-06-09 Gaetano Giunta
+
+ * xmlrpcs.inc: fixed sending of compressed responses when output compression
+ is already enabled in php.ini
+
+ * verify_compat.php: split tests between server and client cases
+
+2006-05-29 Gaetano Giunta
+
+ * added new file: verify_compat.php, to help troubleshooting platform
+ support for the library; added it to makefile, too
+
+2006-05-24 Gaetano Giunta
+
+ * xmlrpc.inc: removed residual usage of regexp in favour of pregexps; fixed
+ a bug in specifying Host http header with non std ports
+
+2006-05-23 Gaetano Giunta
+
+ * xmlrpc.inc: improvements to wrap_php_function: let it deal correctly
+ with php functions returning xmlrpcresp objs; make it generate also
+ docs for single parameters (useful for documenting_xmlrpc_server class)
+
+2006-05-22 Gaetano Giunta
+
+ * xmlrpc.inc, xmlrpcs.inc: minor performance tuning updates: replaced
+ some explode vs. split, ereg vs. preg, single vs. double quotes
+
+ * xmlrpc.inc: fix wrap_xmlrpc_method to NOT rebuild php objects received
+ from the server by default, as it might pose a security risk
+
+2006-04-24 Gaetano Giunta
+
+ * minor fixes makefiles. Tagged and released as 2.0 final
+
+2006-04-22 Gaetano Giunta
+
+ * debugger/*: added option to set cainfo; improve web layout
+
+ * xmlrpc.inc: set sslverifypeer to TRUE instaed of 1 by default
+
+ * doc/php_xmlrpc.xml: documentation updates
+
+2006-04-21 Gaetano Giunta
+
+ * xmlrpc.inc: added option to set ca certs dir instead of single cert
+ (used to validate server in https connetions)
+
+2006-04-18 Gaetano Giunta
+
+ * xmlrpc.inc: fixed bug in xmlrpcval::structmemexists()
+
+ * testsuite.php: added test case for xmlrpcval::structmemexists()
+
+2006-04-03 Gaetano Giunta
+
+ * xmlrpc.inc: add support for Digest and NTLM authentication, both to server
+ and to proxies (note: must use CURL for this to work)
+
+ * debugger/*: add support for Digest/NTLM auth to remote servers
+
+2006-03-19 Gaetano Giunta
+
+ * xmlrpc.inc: fix a bug parsing of 'true' bool values;
+ added a new method to the client class: SetCaCertificate;
+ add column number in xml parsing error messages;
+ fix serialization of messages to ISO-8859-1 charset with php 5 (by adding
+ encoding to the xml prologue of generated messages)
+
+ * xmlrpcs.inc: correct detection of charset in http headers;
+ add column number in xml parsing error messages;
+ fix serialization of responses to ISO-8859-1 charset with php 5 (by adding
+ encoding to the xml prologue of generated responses)
+
+ * testsuite.php: added two more tests on charset encoding
+
+ * NEWS: update info for impending release
+
+2006-03-23 Gaetano Giunta
+
+ * added a new demo file: simple_call.php
+
+2006-02-20 Gaetano Giunta
+
+ * xmlrpcs.inc: more error checking and logging with regard to user-coded
+ method handler functions not being well behaved;
+ fix a case where error handler would not be reset upon user function
+ returning not valid xmlrpresp
+
+ * xmlrpc.inc: fix bug in detection of php 4.3.0
+
+ * Makefile: fix uppercase filenames
+
+2006-02-15
+
+ * xmlrpc.inc: parse 'true' and 'false' as valid booleans, even though the
+ spec is quite clear on that; fix small bug w. internal_encoding = utf8; add
+ definition of $GLOBALS['xmlrpcNull'] for extensibility, e.g. json or
+ extensions to the xmlrpc spec
+
+2006-02-05 Gaetano Giunta
+
+ * xmlrpc.inc: fix bug in wrap_xmlrpc_method if client passed to function has
+ return_type=phpvals
+
+ * all demo files: review code, add more comments and information
+
+ * added 2 demo files: proxy.php (implementing an xmlrpc proxy server) and
+ wrap.php (showing usage of wrap_method_call)
+
+2006-02-04 Gaetano Giunta
+
+ * xmlrpc.inc: fix bug in multicall in case of no fallback and server error
+
+2006-01-30 Gaetano Giunta
+
+ * xmlrpc.inc: fix recursive serialization of xmlrpcvals loosing UTF8 charset;
+ correctly set type field of xmlrpcvals returned by send() calls
+
+ * xmlrpcs.inc: add to server checks for correct return type of user-coded
+ method handling function; tolerate xmlrpcval instead of xmlrpcresp
+
+ * minor change in xmlrpcresp internals, to ease subclassing (store payload
+ in an internal var on serialize(), same as xmlrpcclient does)
+
+2006-01-22 Gaetano Giunta
+
+ * benchmark.php: do not run http 1.1 tests if CURL notfound
+
+ * Released as 2.0 Rc3
+
+2006-01-19 Gaetano Giunta
+
+ * xmlrpc.inc: make xmlrpc_client::setDebug() accept int values instead of
+ boolean. At level 2, the request payload is printed to screen before being
+ sent; fix bug with repeated sending of the same msg object and using request
+ compression w. php 5.1.2 (objects passed by ref by default!!!)
+
+ * xmlrpcs.inc: fix detection of clients accepting compressed responses
+
+ * comment.php: remove warnings due to liberal usage of $HTTP_POST/GET_VARS
+
+ * benchmark.php: add a test using http compression of both requests and
+ responses
+
+ * testsuite.php: added test for fix in xmlrpc.inc
+
+2006-01-17 Gaetano Giunta
+
+ * xmlrpcs.php: minor fix: do not raise a PHP warning when std server is
+ called via GET (global HTTP_RAW_POST_DATA undefined). Some might have called
+ it a security breach (path disclosure)...
+
+2006-01-15 Gaetano Giunta
+
+ * testsuite.php: minor fix to expected date format in http cookie hedaer
+ to cope with PHP 5.1.2
+
+2006-01-05 Gaetano Giunta
+
+ * xmlrpcs.inc: merge code from the 'extras' subclass that allows server
+ to register plain php functions in dispatch map instead of functions
+ accepting a single xmlrpcmgs obj parameter.
+ One step closer to the kitchen sink!!!
+
+2005-12-31 Gaetano Giunta
+
+ * xmlrpcs.inc: let the server accept 'class::method' syntax in the dispatch
+ map
+
+ * testsuite.php, server.php: added new tests for the recent charset encoding
+ capabilities
+
+2005-12-24 Gaetano Giunta
+
+ * xmlrpc.inc: correctly serialize() string xmlrpcvals that have been
+ created out of non-string php variables, when internal encoding is UTF8;
+ serialize to '0' int and double values created out of non-string php
+ variables, eg. 'hello', instead of creating invalid xmlrpc;
+ extend the php_xmlrpc_encode function to allow serializing string values
+ to charsets other tha US-ASCII;
+ minor tweak to xml parsing to allow correct parsing of empty strings when
+ in 'direct to php values' mode
+
+ * xmlrpcs.inc: advances in system.multicall with plain php values
+
+2005-12-17 Gaetano Giunta
+
+ * xmlrpcs.inc: let the functions implementing the system.* methods work
+ fine when called with plain php values as parameters instead of xmlrpcmsg
+ objects (multicall not quite finished yet...);
+ encode level 3 debug info as base64 data, to avoid charset encoding hell
+
+ * xmlrpc.inc: added a new xmlrpc_2_php_type function, to get the name of
+ php types corresponding to xmlrpc types;
+ in debug mode, when detecting base64 server debug info, print it out fine
+
+ * server.php: cosmetic fixes
+
+2005-12-09 Gaetano Giunta
+
+ * xmlrpc.inc: remove one warning emitted when received xml contains an
+ unknown tag; remove warnings emitted when custom error handler is set
+ and user calls php_xmlrpc_encode/decode without the 2nd parameter
+
+ * xmlrpcs.inc: added a param to service(), to allow the server to parse
+ data other than the POST body (useful for subclassing and debugging);
+ reworked the implementation of server debug messages at debug level 2:
+ since the debug info generated has no known charset, and putting it back
+ into the response's xml would most likely break it, send it back to the
+ client as a base64 encoded comment. Clients can decode it if they need it...
+ Add some more javadocs
+
+ * testsuite.php: modified the string test, to see if the server can echo
+ back to the client the received data without breaking the response's xml
+
+2005-12-05 Gaetano Giunta
+
+ * xmlrpc.inc, xmlrpcs.inc: let server and client objects decide if they
+ want to use some charset encoding other than US-ASCII for serialized data:
+ add a new var to both objects, and lots of parameters to function calls
+ that took none up to now;
+ refactored server method service() and parseRequest(), implementing a
+ new parserequestHeaders() method to explicitly deal with HTTP
+
+2005-12-01 Gaetano Giunta
+
+ * moved the jsonrpc implementation and the new wsdl stuff to a separate
+ CVS module; updated the makefile to reflect it
+
+2005-11-24 Gaetano Giunta
+
+ * modified php_xmlrpc_decode() to work on xmlrpcmessages too, besides
+ xmlrpcvals. To achieve this, added a new method: xmlrpcmsg::kindOf()
+
+2005-11-22 Gaetano Giunta
+
+ * released as 2.0 RC2
+
+2005-11-21 Gaetano Giunta
+
+ * xmlrpc.inc: fix warnings about references for PHP 4.1.X
+
+ * Whitespace cleanup on all the lib
+
+2005-11-16 Gaetano Giunta
+
+ * xmlrpc.inc: rewritten xmlrpc_encode_entitites adding two extra parameters
+ that specify input and output charset encodings. This corrects the bug that
+ prevented native UTF-8 strings to be correctly serialized (to have them
+ encoded the user must set $xmlrpc_internalencoing appropriately).
+
+ * xmlrpc.inc: added new method xmlrpcmsg::parseResponseHeaders(), refactoring
+ parseResponse(). This makes the code more modular and eases subclassing.
+
+ * xmlrpc.inc: set cookies and http headers to xmlrpcresp objs even when calls
+ to send() do not complete correctly
+
+ * added new file: jsonrpcs.inc, to accomodate server jsonrpc objects in the future
+
+ * jsonrpc.inc: slow progress...
+
+2005-11-10 Gaetano Giunta
+
+ * xmlrpc.inc: fixed the xmlrpc_client send and sendpayloadhttps methods
+ to fix errors in calling https servers;
+ added a new xmlrpc_client->setkey method to allow usage of client-side ssl
+ certs in recent php builds;
+ added to xmlrpcresp objects a content_type var, to be used in HTTP headers
+
+ * xmlrpcs.inc: separate generation of content-type http header and xml prologue
+ from the service() method, to ease subclassing
+
+2005-11-03 Gaetano Giunta
+
+ * xmlrpc.inc: moved the 'text/xml' mimetype string as class var of the xmlrpcmsg
+ object instead of having it cabled into xmlrpc_client->send(): this allows to
+ create subclasses of xmlrpcmsg that use a different mimetype
+
+ * jsonrpc.inc: added a new file, with an extremely experimental set of classes,
+ designed to implement a json-rpc client and server, taking advantage of the
+ existing xml-rpc infrastructure
+
+2005-10-28 Gaetano Giunta
+
+ * xmlrpc.inc: changed constructor method for xmlrpcresp, making it smarter in
+ case user does not declare the type of value it is passing to it;
+ minor changes in serialization of xmlrpcresp with error codes, so that it
+ utputs LF instead of CRLF on windows boxes after an FTP transfer of the code, too
+
+2005-10-26 Gaetano Giunta
+
+ * xmlrpc.inc: added a new var of class xmlrpc_client, indicating what kind of
+ object will be stored in the value() of xmlrpcresp's gotten from the send()
+ method: xmlrpxc objects, plain php variables or raw xml. This allow the coder
+ to make use of xmlrpc_decode for better performances if he wishes so.
+ Modified creator of xmlrpcresp class to allow it to distinguish between being
+ created out of raw xml or a plain php string (in the former case, serialization
+ is still possible, opening a new world of opportunity for server-side programming:
+ the php function implementing a web service has to provide the xml for the
+ return value on its own).
+ Modified xmlrpc_client::multicall() to suit; also added a new parameter which
+ allows calls to multicall without automatic fallback to many-calls in case of
+ error (speeding up the process of doing a failed multicall() call quite a bit)
+ Fixed two bugs in guess_encoding.
+ Audited all regexps and fixed some.
+ xmlrpc_client::send() does not call xmlrpcmsg::parseresponsefile() anymore.
+ Shuffled parseresponse() a little bit
+
+ * testsuite.php: added a new testcase for the modifications to multicall():
+ now we test the case where xmlrpc_client returns php values, too
+
+2005-10-24 Gaetano Giunta
+
+ * xmlrpc.inc: fixed guess_encoding() to always return uppercase chars
+
+ * added new file: benchmark.php. It contains a few tests used to evaluate
+ speed of the lib in common use cases
+
+ * added file parse_args.php, containing common code for benchmark and
+ testsuite, and modified testsuite.php accordingly
+
+ * modified makefile adding new files
+
+ * testsuite.php: added a couple of new test cases; fixed one warning
+ emitted in php 5 E_STRICT mode
+
+2005-10-20 Gaetano Giunta
+
+ * xmlrpc.inc: modify 3d param of ParseResponse(), allowing the function to
+ return the raw xml received as value of the xmlrpcresponse object.
+ This allows eg. to have epi-xmlrpc decode the xml for faster execution.
+
+2005-10-09 Gaetano Giunta
+
+ * xmlrpc.inc: fixed error that prevented usage of HTTPS (the client
+ always determined that ssl support was not present)
+
+2005-10-03 Gaetano Giunta
+
+ * xmlrpc.inc, xmlrpcs.inc: revert direction of stack growth during xml
+ parsing for faster execution time; add support for detecting charset
+ encoding of received xml; add support for cookies; better parsing of
+ javadoc when building stub code in wrap_php_function; add a lot of
+ javadoc comments everywhere; rewrite most error messages
+
+ * testsuite.php: add many tests for newly introduced features
+
+ * server.php: add a couple of new functions to support debugging new
+ features
+
+ * debugger: add switches to enable all the latest lib features; minor
+ improvements to layout
+
+ * synch included phpunit with latest PEAR release
+
+ * reorganize files included in the distribution in a new hierarchy of folders
+
+ * bump revision number to 2.0RC1 and release
+
+2005-8-14 Miles Lott
+
+ * xmlrpc.inc, xmlrpcs.inc: Remove all use of eval() to avoid potential
+ security hole.
+
+ * As of this release we are no longer php3-compatible.
+
+2005-8-10 Miles Lott
+
+ * xmlrpc.inc, xmlrpcs.inc: Switched to using $GLOBALS instead of calling
+ global $varname
+
+2005-07-22 Miles Lott
+
+ * Removed: bug_* files
+
+2005-07-14 Gaetano Giunta
+
+ * debugger: added a workaround to disable using the debugger for attacking
+ older versions of the lib
+
+ * testsuite.php: added code to test wrap_xmlrpc_method;
+ use different wording for failed tests
+
+ * xmlrpcs.inc: change for() with foreach() in system.* methods implementations;
+ remove a possible cause of php warning;
+
+ * xmlrpc.inc: let wrap_php_function and wrap_xmlrpc_method find suitable
+ function names if default function names are already in use;
+ correct wrap_xmlrpc_method to not set http protocol to 1.0 when not asked to;
+ detect curl compiles without SSL
+
+2005-07-14 Gaetano Giunta
+
+ * xmlrpc.inc: more auto-fix of xmlrpc_client path: '' -> '/';
+ change to the method used for detecting failed evals (php 4.0.x compatibility);
+ complete rework of return-by-ref functions to comply with php 4.4.0
+
+ * xmlrpcs.inc: change to the method used for detecting failed evals (php 4.0.x
+ compatibility)
+
+ * testsuite.php: major rewrite of the multi- tests, to give better feedback on
+ number of failed tests;
+ flush html page title to screen before starting tests;
+
+2005-07-13 Gaetano Giunta
+
+ * xmlrpc.inc: let xmlrpcmsg creator be forgiving of target paths that miss the
+ starting '/' char;
+ completely reworked assign-by-ref to be compliant with php 4.4.0 stricter
+ warnings
+
+ * testsuite.php: added ability to be run from cli: (really dumb) separation of
+ html and plain text outputs + parsing of argv parameters
+
+2005-07-12 Gaetano Giunta
+
+ * xmlrpc.inc: compatibility fixes with PHP versions 4.0.x (and remove some for
+ PHP 3)
+
+ * xmlrpcs.inc: compatibility fixes for PHP 4.0.x versions
+
+ * testsuite.php: better support for running with php versions 4.0.x;
+ do not generate runtime errors but finish tests anyway if some calls to
+ localhost fail;
+ correctly detect a localhost port different from 80 for running tests against
+
+2005-07-11 Gaetano Giunta
+
+ * xmlrpc.inc: preliminary building of method signature and docs in
+ wrap_php_function;
+ fix a bug in extracting function description from javadoc block in
+ wrap_php_function;
+ small fix for better compatibility with php < 4.2.0
+
+ * added compat subdir with extra code, taken form PEAR package Compat, to let
+ the lib run fine with php 4 versions < 4.1
+
+2005-07-10 Gaetano Giunta
+
+ * xmlrpc.inc: some nazi whitespace corrections;
+ declared global $xmlrpcBoolean too (was the only one missing);
+ used @eval inside getval() to have less path disclosure security reports filed
+ in the future;
+ added new global var: $xmlrpcValue, to be used in server dispatch maps as
+ placeholder for a param which can be of any kind;
+ big chunks (but still incomplete) of javadoc parsing in wrap_php_function
+ + changed type of return val - now it is the complete array to be put in the
+ dispatch map
+
+ * xmlrpcs.inc: let previous error handler be called by server to handle errors
+ even if in debug level 3;
+ default to compress responses if zlib installed;
+ added a new val useful for only checking number (not type) of params in method
+ calls;
+ let user use object methods in dispatch map using the
+ array($obj, 'fmethodname') format
+
+ * server.php: Added code called by testsuite.php to exercise registration of
+ object methods as xmlrpc methods and auto-registration of php functions as xmlrpc
+ methods
+
+ * testsuite.php: added tests to exercice server registering object methods as
+ xmlrpc methods and automatic registration of php functions as server methods;
+ added a hint to enable debug if some test goes wrong;
+ renamed https test for better clarity
+
+2005-07-07 Gaetano Giunta
+
+ * xmlrpc.inc: added function to be used for 'guestimating' charset encoding of
+ received xml (not activated yet)
+
+ * server.php: Let server compress content by default if user asks so: it allows
+ testsuite to check for compressed responses
+
+ * testsuite.php: added suite of tests for compressed responses; test CURL
+ (http1.1) with all possible compression combinations too
+
+2005-07-06 Gaetano Giunta
+
+ * xmlrpc.inc: Enable setting usage of keepalives on/off (for CURL cases);
+ implement compression of xmlrpc requests; enable new syntax of xmlrpclient
+ constructor: 1 - allow preferred http method to be set at creation time,
+ 2 - allow user to insert a single complete URL as only parameter and parse it;
+ try to detect if curl is present whether it has been compiled w. zlib to enable
+ automatically the reception of compressed responses
+
+ * xmlrpcs.inc: do not add into logs the content of the request, if it was
+ received gzipped/deflated, to avoid breaking the xml sent back as response
+ (NB: might be investigated further: is the problem caused by windows chars in
+ the range 128-160 ?)
+
+ * testsuite.php: run all localhost tests 2 more times, to stress request
+ compression;
+ run all localhost tests in a row using keepalives, to test keepalive
+ functionality
+
+2005-07-05 Gaetano Giunta
+
+ * xmlrpc.inc: let CURL pass back to caller function the complete PHP headers
+ as it did before: it enables better logging / debugging of communication;
+ small change to the way CURL declares its ability to receive compressed
+ messages (fix for the case where zlib is compiled in PHP but not in curl);
+ added Keep-alive (ON BY DEFAULT) for http 1.1 and https messages (had to modify
+ a lot of functions for that);
+ always make sure a 'Connection: close' header is sent with curl connections if
+ keep-alive is not wanted
+
+ * phpunit.php: switched to PEAR PHPUnit (rel 1.2.3), since it is maintained a
+ lot more than the old version we were using
+
+ * added new folder with code of phpunit classes
+
+ * testsuite.php: added a new run of tests to check for compliance of client
+ when using http 1.1;
+ switched to PEAR PHPUnit classes;
+ divided test for client ability to do multicall() into 2 separate tests
+
+2005-06-30 Gaetano Giunta
+
+ tagged and released version 1.1.1, backporting security fixes from HEAD
+
+2005-06-28 Gaetano Giunta
+
+ * xmlrpcs.inc: fix changes introuced yesterday in a rush;
+ do not list system.* methods for a server that has them explicitly disabled
+
+ * bug_inject.xml: new test case used to check for code injection vulnerability
+
+ * testsuite.php: added a test case for zero parameters method calls;
+ added two test cases for recently found code injection vulnerabilities
+
+2005-06-27 Gaetano Giunta
+
+ * xmlrpc.inc: (tentative) fix for security problem reported by
+ security@gulftech.org: we were not properly php-escaping xml received for
+ BASE64 and NAME tags;
+ some more patching related to junk received in xml messages/responses: if the
+ PHP code built from the parsed xml is broken, catch any generated errors
+ without echoing it to screen but take note of the error and propagate to user
+ code
+
+ * xmlrpcs.inc: some more patching related to junk received in xml messages/
+ responses: if the PHP code built from the parsed xml is broken, catch any
+ generated errors without echoing it to screen but take note of the error and
+ propagate to user code
+
+2005-06-24 Gaetano Giunta
+
+ * xmlrpc.inc: fixed php_xmlrpc_encode detection of php arrays (again!);
+ removed from wrap_php_function the part about setting a custom error handler
+ (it can be activated using the more general $server->setdebug(3) anyway)
+
+ * xmlrpcs.inc: added to server the capability to trap all processing errors
+ during execution of user functions and add them to debug info inside responses;
+ return a (new) xmlrpcerr response instead of raising some obscure php execution
+ error if there is an undefined function in the dispatch map
+
+ * testsuite.php: Added new testcases for recently implemented stuff
+
+2005-06-23 Gaetano Giunta
+
+ * xmlrpc.inc: added new method: xmlrpcval->structmemexists, to check for
+ presence of a wanted struct member without having to loop through all members;
+ fix wrap_php_functions: correctly return false for php internal functions,
+ whose param list is unknown;
+ let addscalar fail as it should if called on struct vals;
+ fix addstruct: do not fail when called for adding stuff to initialized structs;
+ removed a warning generated when calling addscalar with inexistent type;
+ massive code review for speed: replaced each() loops with foreach(), removed
+ lots of useless assignments and duplications of data;
+ added 'http11' as valid method param for xmlrpclient->send: makes use of curl
+ for sending http 1.1 requests;
+ changed a couple '=' into '=&' where objects are returned;
+ fixed wrap_php_function() to better detect php errors while processing wrapped
+ function
+
+ * xmlrpcs.inc: Fix php warnings generated when clients requested method
+ signature / description for a method that had none in its dispatch map;
+ turned server->debug into an integer value that will change the amount of
+ logging going as comments into xmlrpc responses
+
+ * server.php: set default server debug level to 2
+
+ * testsuite.php: removed calls to deleted functions (xmlrpc_encode,
+ xmlrpc_decode);
+ added html page title describing target servers used for tests;
+ added an assign-by-ref
+
+ * phpunit.php: Do not consider as failures PHP 5 E_STRICT errors (arbitrary
+ choice, but lib is targeted at PHP 4)
+
+2005-06-22 Gaetano Giunta
+
+ * xmlrpc.inc: removed lottsa old code that had been left in commented
+
+ * xmlrpc.inc: fixed setting of proxy port
+
+ * xmlrpc.inc: removed one warning when trying to decompress junk sent as
+ deflated response
+
+ * xmlrpc.inc: changed the error messages (but not the code) that will be found
+ in xmlrpcresponses when there are socket errors, to differentiate from HTTP
+ errors
+
+ * xmlrpc.inc: refactored xmlrpcclient->sendpayloadHTTPS: now it calls a new
+ method (sendpayloadCURL) that could be used also for generating HTTP 1.1
+ requests
+
+ * xmlrpc.inc: added two new methods: wrap_php_function and wrap_xmlrpc_method:
+ designed to let the lazy programmer automagically convert php functions to
+ xmlrpc methods and vice versa. Details are in the code
+
+ * debugger/*: added initial revision of a 'universal xmlrpc debugger'
+
+2005-06-20 Gaetano Giunta
+
+ * xmlrpc.inc: replace usage of 'echo' with error_log when errors arise
+ in manipulation of xmlrpcval objects
+
+ * xmlrpc.inc: replaced with in dump function
+
+ * xmlrpc.inc: added method structsize to xmlrpcval class (alias for arraysize)
+
+ * xmlrpc.inc: addarray() now will add extra members to an xmlrpcval object
+ of array type; addstruct() can be used to add members to an xmlrpcval object
+ of struct type
+
+ * xmlrpcs.inc: Added member allow_system_funcs to server: controls whether the
+ server accepts or not calls to system.* functions
+
+2005-05-10 Gaetano Giunta
+
+ * xmlrpc.inc: fix regression in php_xmlrpc_encode when encoding php hashes;
+ fix decompression of gzip/deflated xmlrpc responses;
+ set user agent string correctly in SSL mode (was forgetting lib name);
+ add allowed encoding http headers in requests;
+ do not pass http headers back from curl to parseresponse, to avoid re-decoding
+ compressed xml or http 100 headers
+
+ * xmlrpcs.inc: added method setDebug;
+ renamed compress_output to compress_response;
+ do not try to set http headers if they have already been sent, because trying
+ to do so will raise a PHP error, and if headers have been sent something has
+ gone wrong already (shall we send a meaningful error response instead?)
+
+2005-05-08 Gaetano Giunta
+
+ * xmlrpcs.inc, xmlrpcs.inc: reverted to usage of '=& new' for better
+ performance on (some) php4 installs.
+ NB: PHP 3 compatibility is deprecated from now on!
+
+ * xmlrpc.inc: decode xmlrpc boolean type to native php boolean
+
+ * xmlrpcs.inc, xmlrpcs.inc: switched $_xh[$parser] to $_xh, since indexing
+ an array by object will give a warning in php 5 (and we were resetting the
+ array of _xh elements on every call anyway)
+
+ * xmlrpc.inc: commented unused code used originally for escaping content
+
+ * xmlrpc.inc: commented deprecated methods xmlrpc_encode and xmlrpc_decode
+
+ * xmlrpc.inc: php_xmlrpc_encode: encode integer-indexed php arrays as xmlrpc
+ arrays instead of structs; if object given to encode is an xmlrpcval return it
+ instead of reencoding (makes easier calling encode on an array of xmlrpcvals)
+
+ * xmlrpcs.inc: added $debug field to server class; if false will prevent
+ the server from echoing debug info back to the client as xml comment
+
+ * xmlrpcs.inc: let the server add to the debug messages the complete request
+ payload received and (if php installed as apache module) http headers, so that
+ the client in debug mode can echo a complete fingerprint of the communication
+
+ * xmlrpcs.inc: changed API of ParseRequest method: now it cannot be called
+ without a 'data' parameter; added 2nd parameter (http encoding); changed the
+ call to this method from inside service() method
+
+ * xmlrpc.inc, xmlrpcs.inc: enable both server and client to parse compressed xml
+ (if php is compiled with zlib); client should also be able to decode chunked
+ http encoding
+
+ * xmlrpc.inc: add support for proxies (only basic auth supported); default port
+ is 8080 (if left unspecified)
+
+ * xmlrpc.inc: use lowercase for names of http headers received (makes using
+ them much simpler, since servers can use any upper/lowercase combination)
+
+ * xmlrpc.inc: bumped version number to '2.0 beta'
+
+2005-05-08 Gaetano Giunta
+
+ * release of version 1.1
+
+2005-04-24 Gaetano Giunta
+
+ * xmlrpcs.inc: removed charset declaration from xml prologue of responses,
+ since we are now escaping all non-ascii chars in an encoding-independent way
+
+ * bug_http.xml: modified to exercise some extra functonality of the lib
+ (it should now be failed by the current PEAR implementation of the lib)
+
+ * xmlrpc.inc: bumped up rev. number to 1.1
+
+ * doc/xmlrpc_php.xml, doc/announce1_1.txt: documentation updates
+
+ * Makefile: updated to reflect new xml doc source, modified filelist
+
+2005-04-17 Gaetano Giunta
+
+ * client.php, agesort.php, introspect.php, introspect_demo.php,
+ which.php, test.pl, test.py: use as default target the server.php page hosted
+ on phpxmlrpc.sf.net
+
+ * server.php: fix for register_globals off; refer to docs on phpxmlrpc.sf.net
+
+2005-04-15 Miles Lott
+
+ code formatting and comments
+
+2005-04-03 Gaetano Giunta
+
+ * xmlrpc.inc: make use of global var $xmlrpcName in building User_Agent HTTP
+ header (in conjunction with $xmlrpcVersion)
+
+ * agesort.php, client.php, comment.php, dicuss.php, mail.php, server.php,
+ which.php: various janitorial fixes
+ + always html escape content received from xmlrpc server or from user input
+ + make the scripts run fine with register_globals off an register_long_arrays off
+ + always use the functions php_xmlrpc_en(de)code, even if the EPI extension
+ is not installed
+ + in mail.php, allow user to see script source even if support for .phps files
+ is not configured in the local web server
+
+ * testsuite.php: better detection of local webserver hostname for running tests
+ against (if the user did not supply a webserver name)
+
+2005-03-21 Gaetano Giunta
+
+ * xmlrpcs.inc: revert to a PHP3 compatible script (change '=& new' to '= new')
+
+ * xmlrpc.inc: revert to a PHP3 compatible script (lottsa fixes)
+
+ * testsuite.php: default to using local server as test target if no user
+ provided values are available instead of heddley.com server
+
+ * testsuite.php: play nice to PHP3 in retrieving user-passed values
+
+ * testsuite.php: fix constructor method name for a type of tests
+
+ * phpunit.php: fix all cases of call-time-pass-by-ref
+
+ * phpunit.php: rename Exception class to _Exception if the script is run with
+ PHP 5 (exception is a reserverd word)
+
+2005-03-19 Gaetano Giunta
+
+ * xmlrpc.inc: fixed bug in new http header parsing code in case there is
+ no correct separator between response headers and body
+
+ * xmlrpc.inc: added recognizing and stripping of HTTP/1.1 100 response headers
+
+ * xmlrpc.inc: strip extra whitespace from response body, as well as any junk
+ that comes after the last tag. It allows the server code to
+ be put on public providers that add e.g. javascript advertising to served pages
+
+ * xmlrpc.inc: removed unused parts of code, trailing whitespace
+
+ * xmlrpc.inc: fix possible bug (?) in xmlrpc_ee for BOOLEAN values: true was
+ being handled differently than false
+
+ * testsuite.php: added a new file-based test to stress the response parsing
+ modifications recently introduced; enabled debugging for file based tests
+
+2005-03-15 Gaetano Giunta
+
+ * xmlrpc.inc: fixed missing declaration of global vars in xmlrpc_dh,
+ sendpayloadhttps and sendpayloadhttp10
+
+ * xmlrpc.inc: changed error message for invalid responses: 'enable debugging'
+ is more clear that 'enabling debugging' (the user is being encouraged to do it)
+
+ * xmlrpc.inc: rewrote HTTP response header parsing. It should be more tolerant
+ of invalid headers, give more accurate error messages and be marginally faster,
+ too.
+
+ * xmlrpc.inc: cosmetic whitespace fixes and remove useless one-liners
+
+ * xmlrpc.inc: build a shorter PHP command line to be evaluated for rebuilding
+ values from parsed xml: use '$val =& nex xmlrpcval("value")' for string values
+ instead of '$val =& nex xmlrpcval("value", $xmlrpcString)'
+
+ * xmlrpc.inc: fix change introduced 2005/01/30 moving call to curl_close()
+ too early: it did not work on error situations
+
+ * testsuite.php: fix name of testAddingTest method, renamed testErrosString
+ into testErrorString and removed useless warning for register_globals=off case
+
+2005-02-27 Gaetano Giunta
+
+ * xmlrpc.inc: do not echo XML parsing error to screen (it is already dumped
+ into error log)
+
+ * xmlrpc.inc: set hdrs field into response object in case of XML parsing error
+ (uniform behaviour with other responses)
+
+2005-02-26 Gaetano Giunta
+
+ * xmlrpc.inc: use global var $xmlrpcVersion as number for user agent string
+
+ * xmlrpcs.inc: eliminate server side PHP warning and give back to caller
+ a better error msg in case the called method exists but no signature matches
+ the number of parameters
+
+2005-02-20 Gaetano Giunta
+
+ * xmlrpc.inc: accept a + sign in front of floats / integers, since the spec
+ clearly mentions it
+
+ * xmlrpc.inc, xmlrpcs.inc: renamed function XmlEntities to xmlrpc_encode_entitites,
+ to avoid using the same name as an array already defined
+
+ * xmlrpc.inc: fix bug introduced with escaping of UTF8 chars in xmlrpc error
+ responses: correct behaviour is to escape chars inside serialize(), not when
+ calling the xmlrpcresp creator
+
+ * testsuite.php: made test suite more friendly to modern PHP configs, allowing
+ register_globals to be off and to set in the URL all testing parameters;
+ added tests for newly introduced fixes; renamed existing tests acording to the
+ docs inside phpunit.php (e.g. no subclass of TestCase should have a name
+ starting with test...)
+
+2005-02-19 Gaetano Giunta
+
+ * xmlrpc.inc: accept patch 683153 by mah0: if timeout is set, allow all socket
+ operations to timeout at the given time, not only the socket connection
+
+2005-02-13 Gaetano Giunta
+
+ * xmlrpc.inc: be tolerant to double values received in exponential notation:
+ even though the spec forbids their usage PHP is fine with them
+
+ * xmlrpc.inc: fix bug: new xmlrpcval('-1') was creating an empty value instead
+ of a string value!
+
+ * xmlrpc.inc, xmlrpcs.inc: fix the payload encoding changes introduced by
+ Andres Salomon on 2004-03-17: sending named html entities inside an xml chunk
+ makes it invalid, and thus renders the lib absolutely non-interoperable with
+ any other xmlrpc implementation; moreover the current implementation only ever
+ worked for non-ascii requests, while breaking client-parsing of responses
+ containing non-ascii chars.
+ The principle of using entities is preserved though, because it allows the
+ client to send correct xml regardless of php internal charset encoding vs.
+ xml request charset encoding, but using 'character references' instead.
+
+ * xmlrpc.inc: encode (non-ascii) chars into charset entities also for error
+ strings
+
+ * xmlrpcs.inc: encode (non-ascii) chars into charset entities also for debug
+ messages
+
+ * xmlrpcs.inc: added 'Accept-Charset' header in http request to let the server
+ know what kind of charset encoding we do expect to be used for responses
+
+ * xmlrpc.inc, xmlrpcs.inc: explicitly tell the xml parser what charset the
+ application expects to receive content in (notably strings). A new variable,
+ $xmlrpc_internalencoding, (defaulting to ISO-8859-1) defines what charset the
+ parser will use for passing back string xmlrpcvals to the PHP application
+ (both server-side and client-side).
+ This allows transparent usage of e.g. UTF-8 for encoding xml messages between
+ server and client and ISO-8859-1 for internal string handling.
+ ISO-8859-1 is, AFAIK, PHP internal encoding for all installs except
+ mbstring-enabled ones.
+
+2005-02-12 Gaetano Giunta
+
+ * xmlrpcs.inc: use '$var =& new(' construct to assign objects: on older versions
+ of PHP objects are first built then copied over if the ampersand is omitted.
+ Using it should make the code a little bit faster...
+
+ * doc/xmlrpc.php: update lib version number, release date in preparation for
+ next release
+
+ * makefile: update lib version number in preparation for next release
+
+ * xmlrpc.inc: split up parsing of xmlrpc INT and DOUBLE values. This allows
+ finer-grained control over valid values: now the '.' char is not allowed
+ any more inside int values.
+
+ * xmlrpc.inc: fix for bug #560303: ints and doubles starting with '0' chars are
+ no more parsed as octal values
+
+2005-01-30 Gaetano Giunta
+
+ * xmlrpc.inc: Modifed last change by Miles: the functions php_xmlrpc_encode
+ and php_xmlrpc_decode are now always defined, regardless of the existence of
+ XMLRPC-EPI. This allows users to start using these functions as the 'default'
+ functions, and pave the way for future deprecation of xmlrpc_encode/encode
+ while maintaining a stable API.
+
+ * xmlrpc.inc: use '$var =& new(' construct to assign objects: on older versions
+ of PHP objects are first built then copied over if the ampersand is omitted.
+ Using it should make the code a little bit faster...
+
+ * xmlrpc.inc: close curl connection as soon as possible for https requests:
+ it could save some memory / resources.
+
+ * xmlrpc.inc: added some extra info in the PHP error log message generated
+ when an invalid xmlrpc integer/float value is encountered and we try to
+ deserialize it.
+
+ * xmlrpc.inc: added @ char before fsockopen to avoid echoing useless warnings
+ when connection to server fails; added the same to avoid echoing warnings when
+ deserializing data of an unknown type
+
+ * xmlrpc.inc: reset the _xh array on each xmlrpc call: otherwise a new array
+ member is created for each consecutive call and never destroyed, thus making it
+ impossible to build an xmlrpc-client daemon beacuse of memory leaking.
+
+ * xmlrpc.inc: declare global the variables that are used as 'constants',
+ so that xmlrpc.inc will work even if it is included from within a function
+
+2004-12-27 Miles Lott
+ * xmlrpc.inc: A new constant, XMLRPC_EPI_ENABLED, is defined depending on
+ the existence of the function, xmlrpc_decode. This function will exist in
+ PHP if the extension, XMLRPC-EPI (http://xmlrpc-epi.sourceforge.net), is
+ loaded. It defines the functions xmlrpc_encode and xmlrpc_decode, which
+ will conflict with functions of the same name in xmlrpc.inc. If this
+ extension is loaded, we instead use the names php_xmlrpc_encode and
+ php_xmlrpc_decode. Please look at server.php, testsuite.php, etc., for
+ how this should be handled if using these functions.
+
+2003-04-17 Andres Salomon
+ * xmlrpc.inc: encode strings using htmlentities() instead of
+ htmlspecialchars(), and add xmlrpc_html_entity_xlate(). This
+ should fix longstanding issues with sending weird chars (from
+ non-USASCII codesets like UTF-8, ISO-8859-1, etc) that caused
+ the xml parser to choke. Multi-byte chars are now changed to
+ entities before sending, so that the xmlrpc server doesn't need
+ to know the encoding type of the POST data.
+ * xmlrpcs.inc: call xmlrpc_html_entity_xlate before parsing
+ request packet. The parser chokes on unknown entities (the
+ entities created by htmlentities() are exactly that; html
+ entities, not xml entities), so they must be converted from
+ name form (é) to numerical form (é).
+
+2003-01-12 Andres Salomon
+
+ * released 1.0.99.2.
+ * Makefile: separate doc/Makefile a bit more from Makefile,
+ and add clean rules.
+
+2003-01-10 Andres Salomon
+
+ * xmlrpc.inc: xmlrpcresp and parseResponse cleanups; variable
+ name renames ('xv' to 'val', for example), type checking, and
+ stricter default values.
+ * xmlrpc.inc: fix xmlrpcresp's faultcode; return -1 for FAULT
+ responses from the server whose faultcodes don't reflect any
+ errors.
+
+2003-01-08 Andres Salomon
+
+ * xmlrpc.inc: rename $_xh[$parser]['ha'] to
+ $_xh[$parser]['headers'].
+ * xmlrpc.inc: fix bugs related to $_xh[$parser]['headers];
+ some places treated this as an array, others as a scalar.
+ Treat unconditionally as an array. Also wrap header debugging
+ output in PRE tags.
+
+2002-12-17 Andres Salomon
+
+ * released 1.0.99.
+ * Makefile: changed the tarball format/dist rule to a more
+ conventional form, as well as normal release updates.
+ * xmlrpc.inc: added setSSLVerifyPeer and setSSLVerifyHost; as
+ of curl 7.10, various certificate checks are done (by default).
+ The default for CURLOPT_SSL_VERIFYHOST is to ensure the common
+ name on the cert matches the provided hostname. This breaks a
+ lot of stuff, so allow users to override it.
+ * doc/xmlrpc_php.sgml: updated documentation accordingly.
+
+2002-09-06 Geoffrey T. Dairiki
+
+ Add support for system.multicall() to both the client
+ and the server.
+
+ * testsuite.php: Add new tests 'testServerMulticall',
+ and 'testClientMulticall'.
+
+ * xmlrpc.inc: Added new error messages for system.multicall().
+ * xmlrpcs.inc: Added new procedure call system.multicall().
+ See http://www.xmlrpc.com/discuss/msgReader$1208 for details.
+
+ * xmlrpc.inc: Added system.multicall functionality to
+ xmlrpc_client. xmlrpc_client::send can now take an array of
+ xmlrpcmsg's as an argument. In that case it will attempt
+ to execute the whole array of procure calls in a single
+ HTTP request using system.multicall(). (If that attempt fails,
+ then the calls will be excuted one at a time.) The return
+ value will be an array of xmlrpcresp's (or 0 upon transport
+ failure.)
+
+2001-11-29 Edd Dumbill
+
+ * xmlrpc.inc: fixed problem with processing HTTP headers that
+ broke any payload with more than one consecutive newline in it.
+ also initialise the 'ac' array member to empty string at start.
+ * testsuite.php: added unit test to exercise above bug
+ * xmlrpcs.inc: fixed uninitialized variable $plist
+
+2001-09-25 Edd Dumbill
+
+ * xmlrpc.inc: applied urgent security fixes as identified by Dan
+ Libby
+
+2001-08-27 Edd Dumbill
+
+ * xmlrpc.inc: Merged in HTTPS support from Justin Miller, with a
+ few additions for better traceability of failure conditions. Added
+ small fix from Giancarlo Pinerolo. Bumped rev to 1.0. Changed
+ license to BSD license.
+
+2001-06-15 Edd Dumbill
+
+ * xmlrpcs.inc: Added \r into return MIME headers for server class
+
+2001-04-25 Edd Dumbill
+
+ * server.php: Added interop suite of methods.
+
+2001-04-24 Edd Dumbill
+
+ * testsuite.php: added in test case for string handling bug.
+
+ * xmlrpc.inc: merged in minor fixes from G Giunta to fix
+ noninitialization. Created new method, getval(), which includes
+ experimental support for recreating nested arrays, from Giunta and
+ Sofer. Fixed string handling bug where characters after
+ but before weren't ignored. Added in support for native
+ boolean type into xmlrpc_encode (Giunta).
+
+ * xmlrpcs.inc: updated copyright notice
+
+2001-01-15 Edd Dumbill
+
+ * xmlrpc.inc: fixed bug with creation of booleans. Put checks in
+ to ensure that numbers were really numeric. Fixed bug with
+ non-escaping of dollar signs in strings.
+
+ * testsuite.php: created test suite.
+
+2000-08-26 Edd Dumbill
+
+ * xmlrpcs.inc: added xmlrpc_debugmsg() function which outputs
+ debug information in comments inside the return payload XML
+
+ * xmlrpc.inc: merged in some changes from Dan Libby which fix up
+ whitespace handling.
+
+ * xmlrpcs.inc: added Content-length header on response (bug from
+ Jan Varga . This means you can no longer print
+ during processing
+
+ * xmlrpc.inc: changed ereg_replace to str_replace in several
+ places (thanks to Dan Libby for this).
+
+ * xmlrpc.inc: added xmlrpc_encode() and xmlrpc_decode() from Dan
+ Libby--these helper routines make it easier to work in native PHP
+ data structures.
+
+2000-07-21 Edd Dumbill
+
+ * xmlrpc.inc: added xmlrpc_client::setCredentials method to pass
+ in authorization information, and modified sendPayload* methods to
+ send this OK. Thanks to Grant Rauscher for the impetus to do this.
+ Also, made the client send empty if there are no
+ parameters set by the user.
+
+ * doc/xmlrpc_php.sgml: updated documentation to reflect recent
+ changes
+
+
+2000-07-18 Edd Dumbill
+
+ * server.php: added examples.invertBooleans method to server as a
+ useful test method for boolean values.
+
+ * xmlrpc.inc: rearranged the way booleans are handled to fix
+ outstanding problems. Fixed calling addScalar() on arrays so it
+ works. Finally fixed backslashification issues to remove the
+ problem will dollar signs disappearing.
+
+ * booltest.php: really fixed booleans this time.
+
+2000-06-03 Edd Dumbill
+
+ * xmlrpcs.inc: made signature verification more useful - now
+ returns what it found was wrong
+
+ * xmlrpc.inc: fixed bug with decoding dateTimes. Also fixed a bug
+ which meant a PHP syntax error happened when attempting to receive
+ empty arrays or structs. Also fixed bug with booleans always being
+ interpreted as 'true'.
+
+ * server.php: Added validator1 suite of tests to test against
+ validator.xmlrpc.com
+
+
+2000-05-06 Edd Dumbill
+
+ * released 1.0b6
+
+ * added test.pl and test.py, Perl and Python scripts that exercise
+ server.php somewhat (but not a lot)
+
+ * added extra fault condition for a non 200 OK response from the
+ remote server.
+
+ * added iso8601_encode() and iso8601_decode() to give some support
+ for passing dates around. They translate to and from UNIX
+ timestamps. Updated documentation accordingly.
+
+ * fixed string backslashification -- was previously a little
+ overzealous! new behavior is '\' --> '\\' and '"' -->
+ '\"'. Everything else gets left alone.
+
+2000-04-12 Edd Dumbill
+
+ * updated and bugfixed the documentation
+
+ * fixed base 64 encoding to only happen at serialize() time,
+ rather than when a base64 value is created. This fixes the double
+ encoding bug reported by Nicolay Mausz
+ . The same approach ought to be taken with
+ encoding XML entities in the data - this is a TODO.
+
+ * integrated further code from Peter Kocks: used his new code for
+ send(), adding a second, optional, parameter which is a timeout
+ parameter to fsockopen()
+
+1999-10-11 Edd Dumbill
+
+ * added bug fixes from Peter Kocks
+
+1999-10-10 Edd Dumbill
+
+ * updated the documentation
+
+1999-10-08 Edd Dumbill
+
+ * added system.* methods and dispatcher, plus documentation
+
+ * fixed bug which meant request::getNumParams was returning an
+ incorrect value
+
+ * added signatures into the dispatch map. This BREAKS
+ COMPATIBILITY with previous releases of this code
+
+1999-08-18 Edd Dumbill
+
+ * made entity encoding and decoding transparent now on string
+ passing.
+
+ * de-globalised the globals in the parse routines, using an
+ associative array to hold all parser state $_xh
+
+ * changed default input encoding to be UTF-8 to match expectation
+
+ * separated out parseResponse into parseResponse and
+ parseResponseFile so that you can call parseResponse on a string
+ if you have one handy
+
+1999-07-20 Edd Dumbill
+
+ * Moved documentation into Docbook format
+
+1999-07-19 Edd Dumbill
+
+ * Added an echo server into server.php and echotest.php, a client
+ which will exercise the new echo routine.
+
+ * Added test for no valid value returned: in this case will now
+ throw the error "invalid payload"
+
+ * Added serialize() method to xmlrpcresp to return a string with
+ the response serialized as XML
+
+ * Added automatic encoding and decoding for base64 types
+
+ * Added setDebug() method to client to enable HTML output
+ debugging in the client
+
+1999-07-08 Edd Dumbill
+
+ * Improved XML parse error reporting on the server side to send it
+ back in a faultCode packet. expat errors now begin at 100
+
+1999-07-07 Edd Dumbill
+
+ * Changed the structmem and arraymem methods of xmlrpcval to always
+ return xmlrpc vals whether they referred to scalars or complex
+ types.
+
+ * Added the server class and demonstrations
+
+ * Fixed bugs in the XML parsing and reworked it
diff --git a/php/phpxmlrpc/INSTALL.md b/php/phpxmlrpc/INSTALL.md
new file mode 100644
index 0000000..f78f8f0
--- /dev/null
+++ b/php/phpxmlrpc/INSTALL.md
@@ -0,0 +1,88 @@
+XMLRPC for PHP
+==============
+
+Requirements
+------------
+
+The following requirements should be met prior to using 'XMLRPC for PHP':
+
+* PHP 5.3.0 or later
+
+* the php "curl" extension is needed if you wish to use SSL or HTTP 1.1 to
+ communicate with remote servers
+
+The php "xmlrpc" native extension is not required, but if it is installed,
+there will be no interference with the operation of this library.
+
+
+Installation instructions
+-------------------------
+
+Installation of the library is quite easy:
+
+1. Via Composer (highly recommended):
+
+ 1. Install composer if you don't have it already present on your system.
+ Depending on how you install, you may end up with a composer.phar file in your directory.
+ In that case, no worries! Just substitute 'php composer.phar' for 'composer' in the commands below.
+
+ 2. If you're creating a new project, create a new empty directory for it.
+
+ 3. Open a terminal and use Composer to grab the library.
+
+ $ composer require phpxmlrpc/phpxmlrpc:4.0
+
+ 4. Write your code.
+ Once Composer has downloaded the component(s), all you need to do is include the vendor/autoload.php file that
+ was generated by Composer. This file takes care of autoloading all of the libraries so that you can use them
+ immediately, including phpxmlrpc:
+
+ // File example: src/script.php
+
+ // update this to the path to the "vendor/" directory, relative to this file
+ require_once __DIR__.'/../vendor/autoload.php';
+
+ use PhpXmlRpc\Value;
+ use PhpXmlRpc\Request;
+ use PhpXmlRpc\Client;
+
+ $client = new Client('http://some/server');
+ $response = $client->send(new Request('method', array(new Value('parameter'))));
+
+ 5. IMPORTANT! Make sure that the vendor/phpxmlrpc directory is not directly accessible from the internet,
+ as leaving it open to access means that any visitor can trigger execution of php code such as
+ the built-in debugger.
+
+
+2. Via manual download and autoload configuration
+
+ 1. copy the contents of the src/ folder to any location required by your
+ application (it can be inside the web server root or not).
+
+ 2. configure your app autoloading mechanism so that all classes in the PhpXmlRpc namespace are loaded
+ from that location: any PSR-4 compliant autoloader can do that, if you don't have any there is one
+ available in src/Autoloader.php
+
+ 3. Write your code.
+
+ // File example: script.php
+
+ require_once __DIR__.'my_autoloader.php';
+
+ use PhpXmlRpc\Value;
+ use PhpXmlRpc\Request;
+ use PhpXmlRpc\Client;
+
+ $client = new Client('http://some/server');
+ $response = $client->send(new Request('method', array(new Value('parameter'))));
+
+ 5. IMPORTANT! Make sure that the vendor/phpxmlrpc directory is not directly accessible from the internet,
+ as leaving it open to access means that any visitor can trigger execution of php code such as
+ the built-in debugger.
+
+Tips
+----
+
+Please note that usage of the 'pake' command is not required for installation of the library.
+At this moment it is only useful to build the html and pdf versions of the documentation, and the tarballs
+for distribution of the library.
diff --git a/php/phpxmlrpc/NEWS b/php/phpxmlrpc/NEWS
new file mode 100644
index 0000000..b206cc1
--- /dev/null
+++ b/php/phpxmlrpc/NEWS
@@ -0,0 +1,641 @@
+XML-RPC for PHP version 4.2.0 - 2017/6/30
+
+* improved: allow a DateTimeImmutable object also be detected as a date when encoding
+
+
+XML-RPC for PHP version 4.1.1 - 2016/10/1
+
+* fixed: error in server class: undefined function php_xmlrpc_encode (only triggered when not using the compatibility
+ shim with old versions)
+
+
+XML-RPC for PHP version 4.1.0 - 2016/6/26
+
+* improved: Added support for receiving and integers, sending
+
+ If php is compiled in 32 bit mode, and an i8 int is received from a 3rd party, and error will be emitted.
+ Integers sent from the library to 3rd parties can be encoded using the i8 tag, but default to using 'int' by default;
+ the developer will have to create values as i8 explicitly if needed.
+ The library does *not* check if an outgoing integer is too big to fit in 4 bytes and convert it to an i8 automatically.
+
+
+XML-RPC for PHP version 4.0.1 - 2016/3/27
+
+* improved: all of the API documentation has been moved out of the manual and into the source code phpdoc comments
+
+* fixed: when the internal character set is set to UTF-8 and the client sends requests (or the server responses), too
+ many characters were encoded as numeric entities, whereas some, like åäö, needed not not be
+
+* fixed: the 'valtyp' property of Response was not present in all cases; the ValType property had been added by error
+ and has been removed
+
+
+XML-RPC for PHP version 4.0.0 - 2016/1/20
+
+This release does away with the past and starts a transition to modern-world php.
+
+Code has been heavily refactored, taking care to preserve backwards compatibility as much as possible,
+but some breackage is to be expected.
+
+The minimum required php version has been increased to 5.3, even though we strongly urge you to use
+more recent versions.
+
+PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade.
+
+* new: introduction of namespaces and full OOP.
+
+ All php classes have been renamed and moved to separate files.
+ Class autoloading can now be done in accord with the PSR-4 standard.
+ All global variables and global functions have been removed.
+ Iterating over xmlrpc value objects is now easier thank to support for ArrayAccess and Traversable interfaces.
+
+ Backward compatibility is maintained via lib/xmlrpc.inc, lib/xmlrpcs.inc and lib/xmlrpc_wrappers.inc.
+ For more details, head on to doc/api_changes_v4.md
+
+* changed: the default character encoding delivered from the library to your code is now utf8.
+ It can be changed at any time setting a value to PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding
+
+* improved: the library now accepts requests/responses sent using other character sets than UTF-8/ISO-8859-1/ASCII.
+ This only works when the mbstring php extension is enabled.
+
+* improved: no need to call anymore $client->setSSLVerifyHost(2) to silence a curl warning when using https
+ with recent curl builds
+
+* improved: the xmlrpcval class now supports the interfaces Countable and IteratorAggregate
+
+* improved: a specific option allows users to decide the version of SSL to use for https calls.
+ This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
+ and the cURL extension has been compiled with GnuTLS (such as on Travis VMs)
+
+* improved: the function wrap_php_function() now can be used to wrap closures (it is now a method btw)
+
+* improved: all wrap_something() functions now return a closure by default instead of a function name
+
+* improved: debug messages are not html-escaped any more when executing from the command line
+
+* improved: the library is now tested using Travis ( https://travis-ci.org/ ).
+ Tests are executed using all php versions from 5.3 to 7.0 nightly, plus HHVM; code-coverage information
+ is generated using php 5.6 and uploaded to both Code Coverage and Scrutinizer online services
+
+* improved: phpunit is now installed via composer, not bundled anymore
+
+* improved: when phpunit is used to generate code-coverage data, the code executed server-side is accounted for
+
+* improved: the test suite has basic checks for the debugger and demo files
+
+* improved: more tests in the test suite
+
+* fixed: the server would not reset the user-set debug messages between subsequent service() calls
+
+* fixed: the server would not reset previous php error handlers when an exception was thrown by user code and
+ exception_handling set to 2
+
+* fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml
+ prolog only
+
+* fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml
+ prolog only
+
+* fixed: the function decode_xml() would not decode an xml with character set declaration in the xml prolog
+
+* fixed: the client can now successfully call methods using ISO-8859-1 or UTF-8 characters in their name
+
+* fixed: the debugger would fail sending a request with ISO-8859-1 payload (it missed the character set declaration).
+ It would have a hard time coping with ISO-8859-1 in other fields, such as e.g. the remote method name
+
+* fixed: the debugger would generate a bad payload via the 'load method synopsis' button for signatures containing NULL
+ or undefined parameters
+
+* fixed: the debugger would generate a bad payload via the 'load method synopsis' button for methods with multiple
+ signatures
+
+* improved: the debugger is displayed using UTF-8, making it more useful to debug any kind of service
+
+* improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding;
+ previously those messages would just disappear (this is visible e.g. in the debugger)
+
+* changed: debug info handling
+ - at debug level 1, the rebuilt php objects are not dumped to screen (server-side already did that)
+ - at debug level 1, curl communication info are not dumped to screen
+ - at debug level 1, the tests echo payloads of failures; at debug level 2 all payloads
+
+* improved: makefiles have been replaced with a php_based pakefile
+
+* improved: the source for the manual is stored in asciidoc format, which can be displayed natively by GitHub
+ with nice html formatting. Also the HTML version generated by hand and bundled in tarballs is much nicer
+ to look at than previous versions
+
+* improved: all php code is now formatted according to the PSR-2 standard
+
+
+XML-RPC for PHP version 3.0.0 - 2014/6/15
+
+This release corrects all bugs that have been reported and successfully reproduced since
+version 3.0.0 beta.
+
+The requirements have increased to php 5.1.0 - which is still way older than what you should be running for any serious
+purpose, really.
+
+It also is the first release to be installable via composer.
+
+See the Changelog file or the pdf docs for a complete list of changes.
+
+
+XML-RPC for PHP version 3.0.0 beta - 2009/09/05
+
+This is the first release of the library to only support PHP 5.
+Some legacy code has been removed, and support for features such as exceptions
+and dateTime objects introduced.
+
+The "beta" tag is meant to indicate the fact that the refactoring has been more widespread
+than in precedent releases and that more changes are likely to be introduced with time -
+the library is still considered to be production quality.
+
+* improved: removed all usage of php functions deprecated in php 5.3, usage of assign-by-ref when creating new objects
+ etc...
+* improved: add support for the tag used by the apache library, both in input and output
+* improved: add support for dateTime objects in both in php_xmlrpc_encode and as parameter for constructor of xmlrpcval
+* improved: add support for timestamps as parameter for constructor of xmlrpcval
+* improved: add option 'dates_as_objects' to php_xmlrpc_decode to return dateTime objects for xmlrpc datetimes
+* improved: add new method SetCurlOptions to xmrlpc_client to allow extra flexibility in tweaking http config, such as
+ explicitly binding to an ip address
+* improved: add new method SetUserAgent to xmrlpc_client to to allow having different user-agent http headers
+* improved: add a new member variable in server class to allow fine-tuning of the encoding of returned values when the
+ server is in 'phpvals' mode
+* improved: allow servers in 'xmlrpcvals' mode to also register plain php functions by defining them in the dispatch map
+ with an added option
+* improved: catch exceptions thrown during execution of php functions exposed as methods by the server
+* fixed: bad encoding if same object is encoded twice using php_xmlrpc_encode
+
+
+XML-RPC for PHP version 2.2.2 - 2009/03/16
+
+This release corrects all bugs that have been reported and sucesfully reproduced since
+version 2.2.1.
+Regardless of the intimidating message about dropping PHP 4 support, it still does
+support that ancient, broken and insecure platform.
+
+
+* fixed: php warning when receiving 'false' in a bool value
+* fixed: improve robustness of the debugger when parsing weird results from non-compliant servers
+* fixed: format floating point values using the correct decimal separator even when php locale is set to one that uses
+ comma
+* fixed: use feof() to test if socket connections are to be closed instead of the number of bytes read (rare bug when
+ communicating with some servers)
+* fixed: be more tolerant in detection of charset in http headers
+* fixed: fix encoding of UTF8 chars outside of the BMP plane
+* fixed: fix detection of zlib.output_compression
+* improved: allow the add_to_map server method to add docs for single params too
+* improved: added the possibility to wrap for exposure as xmlrpc methods plain php class methods, object methods and
+ even whole classes
+
+
+XML-RPC for PHP version 2.2.1 - 2008/03/06
+
+This release corrects all bugs that have been reported and sucesfully reproduced.
+It is the last release of the library that will support PHP 4.
+
+* fixed: work around bug in php 5.2.2 which broke support of HTTP_RAW_POST_DATA
+* fixed: is_dir parameter of setCaCertificate() method is reversed
+* fixed: a php warning in xmlrpc_client creator method
+* fixed: parsing of '1e+1' as valid float
+* fixed: allow errorlevel 3 to work when prev. error handler was a static method
+* fixed: usage of client::setcookie() for multiple cookies in non-ssl mode
+* improved: support for CP1252 charset is not part or the library but almost possible
+* improved: more info when curl is enabled and debug mode is on
+
+
+XML-RPC for PHP version 2.2 - 2007/02/25
+
+This release corrects a couple of bugs and adds a few minor features.
+
+* fixed: debugger errors on php installs with magic_quotes_gpc on
+* fixed: support for https connections via proxy
+* fixed: wrap_xmlrpc_method() generated code failed to properly encode php objects
+* improved: slightly faster encoding of data which is internally UTF-8
+* improved: debugger always generates a 'null' id for jsonrpc if user omits it
+* new: debugger can take advantage of a graphical value builder
+ (it has to be downloaded separately, as part of jsxmlrpc package)
+* new: support for the xmlrpc extension
+* new: server support for the system.getCapabilities xmlrpc extension
+* new: wrap_xmlrpc_method() accepts two new options: debug and return_on_fault
+
+
+XML-RPC for PHP version 2.1 - 2006/08/28
+
+This release corrects quite a few bugs and adds some interesting new features.
+There is a minor security enhancement and overall speedup too.
+
+It has been tested with PHP 4.0.5 up to 4.4.4 and 5.1.5.
+Please note that 404pl1 is NOT supported, and has not been since 2.0.
+
+*** PLEASE READ CAREFULLY BELOW ***
+
+CHANGES THAT MIGHT AFFECT DEPLOYED APPLICATIONS:
+
+The wrap_php_function and wrap_xmlrpc_method functions have been moved out of
+the base library file xmlrpc.inc into a file of their own: xmlrpc_wrappers.inc.
+You will have to include() / require() it in your scripts if you have been using
+those functions.
+
+For increased security, the automatic rebuilding of php object instances out of
+received xmlrpc structs in wrap_xmlrpc_method() has been disabled (but it can be
+optionally reenabled).
+
+The constructor of xmlrpcval() values has seen major changes, and it will not
+throw a php warning anymore when invoked using an unknown xmlrpc type: the
+error will only be written to php error log. Also new xmlrpcval('true', 'boolean')
+is not supported anymore.
+
+MAJOR IMPROVEMENTS:
+
+The new function php_xmlrpc_decode_xml() will take the xml representation of
+either an xmlrpc request, response or single value and return the corresponding
+php-xmlrpc object instance.
+
+Both wrap_php_function() and wrap_xmlrpc_method() functions accept many more
+options to fine tune their behaviour, including one to return the php code to
+be saved and later used as standalone php script.
+
+A new function wrap_xmlrpc_server() has been added, to wrap all (or some) of the
+methods exposed by a remote xmlrpc server into a php class.
+
+Lib internals have been modified to provide better support for grafting extra
+functionality on top of it. Stay tuned for future releases of the EXTRAS package.
+
+Last but not least a new file has been added: verify_compat.php, to help users
+diagnose the level of compliance of the current php install with the library.
+
+CHANGELOG IN DETAIL:
+
+* fixed bug 1311927: client not playing nice with some proxy/firewall on ports != 80
+* fixed bug 1334340: all ereg_ functions have been replaced with corresponding preg_
+* fixed bug: wrong handling of 'deflate' http encoding, both server and client side
+* fixed bug: sending compressed responses when php output compression is enabled was not working
+* fixed bug: addarray() and addstruct() where not returning 1 when adding data to already initialized values
+* fixed bug: non-ascii chars used in struct element names where not being encoded correctly
+* restored compatibility with php 4.0.5 (for those poor souls still stuck on it)
+* server->service() now returns either the payload or xmlrpcresp instance
+* server->add_to_map() now accepts methods with no param definitions
+* added new function: php_xmlrpc_decode_xml()
+* added new function: wrap_xmlrpc_server()
+* major improvements and security enhancements to wrap_php_function() and wrap_xmlrpc_method()
+* documentation for single parameters of exposed methods can be added to the dispatch map
+ (and turned into html docs in conjunction with a future release of the extras package)
+* full response payload is saved into xmlrpcresp object for further debugging
+* stricter parsing of incoming xmlrpc messages: two more invalid cases are now detected
+ (double data element inside array and struct/array after scalar inside value element)
+* debugger can now generate code that wraps a remote method into php function (works for jsonrpc, too)
+* debugger has better support for being activated via a single GET call (for integration into other tools?)
+* more logging of errors in a lot of situations
+* javadoc documentation of lib files almost complete
+* the usual amount of new testcases in the testsuite
+* many performance tweaks and code cleanups
+* added foundation for emulating the API of the xmlrpc extension (extras package needed)
+
+
+XML-RPC for PHP version 2.0 - 2006/04/24
+
+I'm pleased to announce XML-RPC for PHP version 2.0, final.
+
+With respect to the last release candidate, this release corrects a few small
+bugs and adds a couple of new features: more authentication options (digest and
+ntlm for servers, ntlm for proxies, and some https custom certificates stuff);
+all the examples have been reviewed and some demo files added,
+including a ready-made xmlrpc proxy (useful e.g. for ajax calls, when the xmlrpc
+client is a browser); the server logs more warning messages for incorrect situations;
+both client and server are more tolerant of commonly-found mistakes.
+The debugger has been upgraded to reflect the new client capabilities.
+
+In greater detail:
+
+* fixed bug: method xmlrpcval::structmemexists($value) would not work
+* fixed bug: wrap_xmlrpc_method would fail if invoked with a client object that
+ has return_type=phpvals
+* fixed bug: in case of call to client::multicall without fallback and server error
+* fixed bug: recursive serialization of xmlrpcvals loosing specified UTF8 charset
+* fixed bug: serializing to ISO-8859-1 with php 5 would raise an error if non-ascii
+ chars where found when decoding
+* new: client can use NTLM and Digest authentication methods for https and http 1.1
+ connections; authentication to proxy can be set to NTLM, too
+* new: server tolerates user functions returning a single xmlrpcval object instead
+ of an xmlrpcresp
+* new: server does more checks for presence and correct return type of user
+ coded method handling functions, and logs inconsistencies to php error log
+* new: client method SetCaCertificate($cert, $is_dir) to validate server against
+* new: both server and client tolerate receiving 'true' and 'false' for bool values
+ (which btw are not valid according to the xmlrpc spec)
+
+
+XML-RPC for PHP version 2.0RC3 - 2006/01/22
+
+This release corrects a few bugs and adds some interesting new features.
+It has been tested with PHP up to 4.4.2 and 5.1.2.
+
+* fixed bug: server not recognizing clients that declare support for http compression
+* fixed bug: serialization of new xmlrpcval (8, 'string') when internal encoding
+ set to UTF-8
+* fixed bug: serialization of new xmlrpcval ('hello', 'int') would produce
+ invalid xml-rpc
+* new: let the server accept 'class::method' syntax in the dispatch map
+* new: php_xmlrpc_decode() can decode xmlrpcmessage objects
+* new: both client and server can specify a charset to be used for serializing
+ values instead of the default 'US-ASCII+xml-entities-for-other-characters'.
+ Values allowed: ISO-8859-1 and UTF-8
+* new: the server object can register 'plain' php functions instead of functions
+ that accept a single parameter of type xmlrpcmsg. Faster, uses less memory
+ (but comes with minor drawbacks as well, read the manual for more details)
+* new: client::setDebug(2) can be used to have the request payload printed to
+ screen before being sent
+* new: server::service($data) lets user parse data other than POST body, for
+ easier testing / subclassing
+* changed: framework-generated debug messages are sent back by the server base64
+ encoded, to avoid any charset/xml compatibility problem
+* other minor fixes
+
+The usual refactoring of a lot of (private) methods has taken place, with new
+parameters added to some functions.
+Javadoc documentation has been improved a lot.
+The HTML documentation has been shuffled around a bit, hoping to give it a more
+logical organization.
+
+The experimental support for the JSON protocol has been removed, and will be
+packaged as a separate download with some extra very interesting stuff (human
+readable auto-generated documentation, anyone?).
+
+
+XML-RPC for PHP version 2.0RC2 - 2005/11/22
+
+This release corrects a few bugs and adds basically one new method for better
+HTTPS support:
+
+ * fixed two bugs that prevented xmlrpc calls to take place over https
+ * fixed two bugs that prevented proper recognition of xml character set
+ when it was declared inside the xml prologue
+ * added xmlrpc_client::setKey($key, $keypass) method, to allow using client
+ side certificates for https connections
+ * fixed bug that prevented proper serialization of string xmlrpcvals when
+ $xmlrpc_internalencoding was set to UTF-8
+ * fixed bug in xmlrpc_server::echoInput() (and marked method as deprecated)
+ * correctly set cookies/http headers into xmlrpcresp objects even when the
+ send() method call fails for some reason
+ * added a benchmark file in the testsuite directory
+
+A couple of (private/protected) methods have been refactored, as well as a
+couple of extra parameters added to some (private) functions - this has no
+impact on the public API and should be of interest primarily to people extending
+/ subclassing the lib.
+
+There is also new, PARTIAL support for the JSON-RPC protocol, implemented in
+two files in the extras dir (more info about json-rpc at http://json-rpc.org)
+
+
+XML-RPC for PHP version 2.0RC1 - 2005/10/03
+
+I'm pleased to announce XML-RPC for PHP version 2.0, release candidate 1.
+
+This release introduces so many new features it is almost impossible to list them
+here, making the library finally on pair with, if not more advanced than, any other
+similar offer (e.g. the PEAR XMLRPC package or the Incutio IXR library).
+No, really, trust me.
+
+The minimum supported PHP version is now 4.2 - natively - or 4.0.4pl1 - by usage of
+a couple of compatibility classes (code taken from PEAR php_compat package).
+
+The placement of files and directories in the distribution has been deeply modified,
+in the hope of making it more clear, now that the file count has increased.
+I hope you find it easy.
+
+Support for "advanced" HTTP features such as cookies, proxies and keep-alives has
+been added at last.
+
+It is now much easier to convert between xmlrpcval objects and php values, and
+in fact php_xmlrpc_encode and php_xmlrpc_decode are now the recommended methods
+for all cases, except when encoding base64 data.
+
+Two new (experimental) functions have been added, allowing automagic conversion
+of a php function into an xmlrpc method to be exposed and vice-versa.
+
+PHP objects can be now automatically serialized as xmlrpc struct values and
+correctly deserialized on the other end of the transmission, provided that the
+same class definition is present on both sides and no object members are of
+type resource.
+
+A lot of the existing class methods have been overloaded with extra parameters
+or new functionality, and a few added ex-novo, making usage easier than ever.
+
+A complete debugger solution is included in the distribution. It needs a web server
+to run (a freely available version of the same debugger is accessible online, it
+can be found at http://phpxmlrpc.sourceforge.net).
+
+For a more detailed list of changes, please read carefully chapter 2 of the
+included documentation, or, even better, take a look at the source code, which
+is commented in javadoc style quite a bit.
+
+
+XML-RPC for PHP version 1.2 - 2005/08/14
+
+This removes all use of eval(), which is a potential security problem.
+All users are encouraged to upgrade as soon as possible.
+As of this release we are no longer php3-compatible.
+
+
+XML-RPC for PHP version 1.1.1 - 2005/06/30
+
+This is a security vulnerability fix release.
+All users are invited to upgrade as soon as possible.
+
+
+XML-RPC for PHP version 1.1 - 2005/05/03
+
+I'm pleased to announce XML-RPC for PHP version 1.1
+It's taken two years to get to the this point, but here we are, finally.
+
+This is a bugfix and maintenance release. No major new features have been added.
+All known bugs have been ironed out, unless fixing would have meant breaking
+the API.
+The code has been tested with PHP 3, 4 and 5, even tough PHP 4 is the main
+development platform (and some warnings will be emitted when running PHP5).
+
+Noteworthy changes include:
+
+ * do not clash any more with the EPI xmlrpc extension bundled with PHP 4 and 5
+ * fixed the unicode/charset problems that have been plaguing the lib for years
+ * proper parsing of int and float values prepended with zeroes or the '+' char
+ * accept float values in exponential notation
+ * configurable http user-agent string
+ * use the same timeout on client socket reads as used for connecting
+ * more explicative error messages in xmlrpcresponse in many cases
+ * much more tolerant parsing of malformed http responses from xmlrpc servers
+ * fixed memleak that prevented the client to be used in never-ending scripts
+ * parse bigger xmlrpc messages without crashing (1MB in size or more)
+ * be tolerant to xmlrpc responses generated on public servers that add
+ javascript advertising at the end of hosted content
+ * the lib generates quite a few less PHP warnings during standard operation
+
+This is the last release that will support PHP 3.
+The next release will include better support for PHP 5 and (possibly) a slew of
+new features.
+
+The changelog is available at:
+http://cvs.sourceforge.net/viewcvs.py/phpxmlrpc/xmlrpc/ChangeLog?view=markup
+
+Please report bugs to the XML-RPC PHP mailing list or to the sourceforge project
+pages at http://sourceforge.net/projects/phpxmlrpc/
+
+
+XML-RPC for PHP version 1.0
+
+I'm pleased to announce XML-RPC for PHP version 1.0 (final). It's taken
+two years to get to the 1.0 point, but here we are, finally. The major change
+is re-licensing with the BSD open source license, a move from the custom
+license previously used.
+
+After this release I expect to move the project to SourceForge and find
+another primary maintainer for the code. More details will follow to the
+mailing list.
+
+It can be downloaded from http://xmlrpc.usefulinc.com/php.html
+
+Comprehensive documentation is available in the distribution, but you
+can also browse it at http://xmlrpc.usefulinc.com/doc/
+
+Bugfixes in this release include:
+
+ * Small fixes and tidying up.
+
+New features include:
+
+ * experimental support for SSL via the curl extensions to PHP. Needs
+ PHP 4.0.2 or greater, but not PHP 4.0.6 which has broken SSL support.
+
+The changelog is available at: http://xmlrpc.usefulinc.com/ChangeLog.txt
+
+Please report bugs to the XML-RPC PHP mailing list, of which more details are
+available at http://xmlrpc.usefulinc.com/list.html, or to
+.
+
+
+XML-RPC for PHP version 1.0 beta 9
+
+I'm pleased to announce XML-RPC for PHP version 1.0 beta 9. This is
+is largely a bugfix release.
+
+It can be downloaded from http://xmlrpc.usefulinc.com/php.html
+
+Comprehensive documentation is available in the distribution, but you
+can also browse it at http://xmlrpc.usefulinc.com/doc/
+
+Bugfixes in this release include:
+
+ * Fixed string handling bug where characters between a
+ and tag were not ignored.
+
+ * Added in support for PHP's native boolean type.
+
+New features include:
+
+ * new getval() method (experimental only) which has support for
+ recreating nested arrays.
+ * fledgling unit test suite
+ * server.php has support for basic interop test suite
+
+The changelog is available at: http://xmlrpc.usefulinc.com/ChangeLog.txt
+
+Please test this as hard as possible and report bugs to the XML-RPC PHP
+mailing list, of which more details are available at
+http://xmlrpc.usefulinc.com/list.html, or to .
+
+
+XML-RPC for PHP version 1.0 beta 8
+
+I'm pleased to announce XML-RPC for PHP version 1.0 beta 8.
+
+This release fixes several bugs and adds a couple of new helper
+functions. The most critical change in this release is that you can no
+longer print debug info in comments inside a server method -- you must
+now use the new xmlrpc_debugmsg() function.
+
+It can be downloaded from http://xmlrpc.usefulinc.com/php.html
+
+Comprehensive documentation is available in the distribution, but you
+can also browse it at http://xmlrpc.usefulinc.com/doc/
+
+Bugfixes in this release include:
+
+ * fixed whitespace handling in values
+ * correct sending of Content-length from the server
+
+New features include:
+
+ * xmlrpc_debugmsg() method allows sending of debug info in comments in
+ the return payload from a server
+
+ * xmlrpc_encode() and xmlrpc_decode() translate between xmlrpcval
+ objects and PHP language arrays. They aren't suitable for all
+ datatypes, but can speed up coding in simple scenarios. Thanks to Dan
+ Libby for these.
+
+The changelog is available at: http://xmlrpc.usefulinc.com/ChangeLog.txt
+
+Please test this as hard as possible and report bugs to the XML-RPC PHP
+mailing list, of which more details are available at
+http://xmlrpc.usefulinc.com/list.html, or to .
+
+
+XML-RPC for PHP version 1.0 beta 7
+
+I'm pleased to announce XML-RPC for PHP version 1.0 beta 7. This is
+fixes some critical bugs that crept in. If it shows itself to be stable
+then it'll become the 1.0 release.
+
+It can be downloaded from http://xmlrpc.usefulinc.com/php.html
+
+Comprehensive documentation is available in the distribution, but you
+can also browse it at http://xmlrpc.usefulinc.com/doc/
+
+Bugfixes in this release include:
+
+ * Passing of booleans should now work as expected
+ * Dollar signs and backslashes in strings should pass OK
+ * addScalar() now works properly to append to array vals
+
+New features include:
+
+ * Added support for HTTP Basic authorization through the
+ xmlrpc_client::setCredentials method.
+
+ * Added test script and method for verifying correct passing of
+ booleans
+
+The changelog is available at: http://xmlrpc.usefulinc.com/ChangeLog.txt
+
+Please test this as hard as possible and report bugs to the XML-RPC PHP
+mailing list, of which more details are available at
+http://xmlrpc.usefulinc.com/list.html, or to .
+
+
+XML-RPC for PHP version 1.0 beta 6
+
+I'm pleased to announce XML-RPC for PHP version 1.0 beta 6. This is the
+final beta before the 1.0 release.
+
+It can be downloaded from http://xmlrpc.usefulinc.com/php.html
+
+Comprehensive documentation is available in the distribution, but you
+can also browse it at http://xmlrpc.usefulinc.com/doc/
+
+New features in this release include:
+
+ * Perl and Python test programs for the demo server
+ * Proper fault generation on a non-"200 OK" response from a remote host
+ * Bugfixed base64 decoding
+ * ISO8601 helper routines for translation to and from UNIX timestamps
+ * reorganization of code to allow eventual integration of alternative
+ transports
+
+The changelog is available at: http://xmlrpc.usefulinc.com/ChangeLog.txt
+
+Please test this as hard as possible and report bugs to the XML-RPC PHP
+mailing list, of which more details are available at
+http://xmlrpc.usefulinc.com/list.html, or to .
diff --git a/php/phpxmlrpc/README.md b/php/phpxmlrpc/README.md
new file mode 100644
index 0000000..2b48d5e
--- /dev/null
+++ b/php/phpxmlrpc/README.md
@@ -0,0 +1,48 @@
+XMLRPC for PHP
+==============
+A php library for building xml-rpc clients and servers.
+
+Installation
+------------
+The recommended way to install this library is using Composer.
+
+Detailed installation instructions are in the [INSTALL.md](INSTALL.md) file, along with system requirements listing.
+
+Documentation
+-------------
+
+*NB: the user manual has not been updated yet with all the changes made in version 4. Please consider it unreliable!*
+
+*You are encouraged to look instead the code examples found in the demo/ directory*
+
+The user manual can be found in the doc/manual directory, in Asciidoc format: [phpxmlrpc_manual.adoc](doc/manual/phpxmlrpc_manual.adoc)
+
+Release tarballs also contain the HTML and PDF versions, as well as an automatically generated API documentation.
+
+Upgrading
+---------
+If you are upgrading from version 3 or earlier you have two options:
+
+1. adapt your code to the new API (all changes needed are described in [doc/api_changes_v4.md](doc/api_changes_v4.md))
+
+2. use instead the *compatibility layer* which is provided. Instructions and pitfalls described in [doc/api_changes_v4.md](doc/api_changes_v4.md##enabling-compatibility-with-legacy-code)
+
+In any case, read carefully the docs in [doc/api_changes_v4.md](doc/api_changes_v4.md) and report back any undocumented
+issue using GitHub.
+
+License
+-------
+Use of this software is subject to the terms in the [license.txt](license.txt) file
+
+SSL-certificate
+---------------
+The passphrase for the rsakey.pem certificate is 'test'.
+
+
+[![License](https://poser.pugx.org/phpxmlrpc/phpxmlrpc/license)](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
+[![Latest Stable Version](https://poser.pugx.org/phpxmlrpc/phpxmlrpc/v/stable)](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
+[![Total Downloads](https://poser.pugx.org/phpxmlrpc/phpxmlrpc/downloads)](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
+
+[![Build Status](https://travis-ci.org/gggeek/phpxmlrpc.svg?branch=php53)](https://travis-ci.org/gggeek/phpxmlrpc)
+[![Test Coverage](https://codeclimate.com/github/gggeek/phpxmlrpc/badges/coverage.svg)](https://codeclimate.com/github/gggeek/phpxmlrpc)
+[![Code Coverage](https://scrutinizer-ci.com/g/gggeek/phpxmlrpc/badges/coverage.png?b=php53)](https://scrutinizer-ci.com/g/gggeek/phpxmlrpc/?branch=php53)
diff --git a/php/phpxmlrpc/composer.json b/php/phpxmlrpc/composer.json
new file mode 100644
index 0000000..b3cfafa
--- /dev/null
+++ b/php/phpxmlrpc/composer.json
@@ -0,0 +1,45 @@
+{
+ "name": "phpxmlrpc/phpxmlrpc",
+ "description": "A php library for building xmlrpc clients and servers",
+ "license": "BSD-3-Clause",
+ "homepage": "http://gggeek.github.io/phpxmlrpc/",
+ "keywords": [ "xmlrpc", "webservices" ],
+ "require": {
+ "php": ">=5.3.0",
+ "ext-xml": "*"
+ },
+ "require-dev": {
+ "phpunit/phpunit": ">=4.0.0, <6.0.0",
+ "phpunit/phpunit-selenium": "*",
+ "codeclimate/php-test-reporter": "dev-master",
+ "ext-curl": "*",
+ "ext-mbstring": "*",
+ "indeyets/pake": "~1.99",
+ "sami/sami": "~3.1",
+ "docbook/docbook-xsl": "~1.78"
+ },
+ "suggest": {
+ "ext-curl": "Needed for HTTPS and HTTP 1.1 support, NTLM Auth etc...",
+ "ext-zlib": "Needed for sending compressed requests and receiving compressed responses, if cURL is not available",
+ "ext-mbstring": "Needed to allow reception of requests/responses in character sets other than ASCII,LATIN-1,UTF-8"
+ },
+ "autoload": {
+ "psr-4": {"PhpXmlRpc\\": "src/"}
+ },
+ "config": {
+ "secure-http": false
+ },
+ "repositories": [
+ {
+ "type": "package",
+ "package": {
+ "name": "docbook/docbook-xsl",
+ "version": "1.78.1",
+ "dist": {
+ "url": "https://sourceforge.net/projects/docbook/files/docbook-xsl/1.78.1/docbook-xsl-1.78.1.zip/download",
+ "type": "zip"
+ }
+ }
+ }
+ ]
+}
diff --git a/php/phpxmlrpc/debugger/action.php b/php/phpxmlrpc/debugger/action.php
new file mode 100644
index 0000000..0d0a649
--- /dev/null
+++ b/php/phpxmlrpc/debugger/action.php
@@ -0,0 +1,565 @@
+
+
+
+
+ XMLRPC Debugger
+
+
+
+
+ 1) {
+ $pport = $pproxy[1];
+ } else {
+ $pport = 8080;
+ }
+ $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd);
+ }
+
+ if ($protocol == 2) {
+ $client->setSSLVerifyPeer($verifypeer);
+ $client->setSSLVerifyHost($verifyhost);
+ if ($cainfo) {
+ $client->setCaCertificate($cainfo);
+ }
+ $httpprotocol = 'https';
+ } elseif ($protocol == 1) {
+ $httpprotocol = 'http11';
+ } else {
+ $httpprotocol = 'http';
+ }
+
+ if ($username) {
+ $client->setCredentials($username, $password, $authtype);
+ }
+
+ $client->setDebug($debug);
+
+ switch ($requestcompression) {
+ case 0:
+ $client->request_compression = '';
+ break;
+ case 1:
+ $client->request_compression = 'gzip';
+ break;
+ case 2:
+ $client->request_compression = 'deflate';
+ break;
+ }
+
+ switch ($responsecompression) {
+ case 0:
+ $client->accepted_compression = '';
+ break;
+ case 1:
+ $client->accepted_compression = array('gzip');
+ break;
+ case 2:
+ $client->accepted_compression = array('deflate');
+ break;
+ case 3:
+ $client->accepted_compression = array('gzip', 'deflate');
+ break;
+ }
+
+ $cookies = explode(',', $clientcookies);
+ foreach ($cookies as $cookie) {
+ if (strpos($cookie, '=')) {
+ $cookie = explode('=', $cookie);
+ $client->setCookie(trim($cookie[0]), trim(@$cookie[1]));
+ }
+ }
+
+ $msg = array();
+ switch ($action) {
+ // fall thru intentionally
+ case 'describe':
+ case 'wrap':
+ $msg[0] = new $requestClass('system.methodHelp', array(), $id);
+ $msg[0]->addparam(new PhpXmlRpc\Value($method));
+ $msg[1] = new $requestClass('system.methodSignature', array(), $id + 1);
+ $msg[1]->addparam(new PhpXmlRpc\Value($method));
+ $actionname = 'Description of method "' . $method . '"';
+ break;
+ case 'list':
+ $msg[0] = new $requestClass('system.listMethods', array(), $id);
+ $actionname = 'List of available methods';
+ break;
+ case 'execute':
+ if (!payload_is_safe($payload)) {
+ die("Tsk tsk tsk, please stop it or I will have to call in the cops!");
+ }
+ $msg[0] = new $requestClass($method, array(), $id);
+ // hack! build xml payload by hand
+ if ($wstype == 1) {
+ $msg[0]->payload = "{\n" .
+ '"method": "' . $method . "\",\n\"params\": [" .
+ $payload .
+ "\n],\n\"id\": ";
+ // fix: if user gave an empty string, use NULL, or we'll break json syntax
+ if ($id == "") {
+ $msg[0]->payload .= "null\n}";
+ } else {
+ if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null') {
+ $msg[0]->payload .= "$id\n}";
+ } else {
+ $msg[0]->payload .= "\"$id\"\n}";
+ }
+ }
+ } else {
+ $msg[0]->payload = $msg[0]->xml_header($inputcharset) .
+ '' . $method . "\n" .
+ $payload .
+ "\n" . $msg[0]->xml_footer();
+ }
+ $actionname = 'Execution of method ' . $method;
+ break;
+ default: // give a warning
+ $actionname = '[ERROR: unknown action] "' . $action . '"';
+ }
+
+ // Before calling execute, echo out brief description of action taken + date and time ???
+ // this gives good user feedback for long-running methods...
+ echo '
' . htmlspecialchars($actionname, ENT_COMPAT, $inputcharset) . ' on server ' . htmlspecialchars($server, ENT_COMPAT, $inputcharset) . " ...
";
+ //}
+ //else
+ //{
+ // echo 'Error while building php code stub...';
+ }
+
+ break;
+
+ case 'execute':
+ echo '
Response:
' . htmlspecialchars($response->serialize()) . '
';
+ break;
+
+ default: // give a warning
+ }
+ } // if !$response->faultCode()
+ } // if $response
+} else {
+ // no action taken yet: give some instructions on debugger usage
+ ?>
+
+
Instructions on usage of the debugger
+
+
Run a 'list available methods' action against desired server
+
If list of methods appears, click on 'describe method' for desired method
+
To run method: click on 'load method synopsis' for desired method. This will load a skeleton for method call
+ parameters in the form above. Complete all xmlrpc values with appropriate data and click 'Execute'
+
+
+ You will need to enable the CURL extension to use the HTTPS and HTTP 1.1 transports
\n";
+ }
+ ?>
+
+
Example
+
+ Server Address: phpxmlrpc.sourceforge.net
+ Path: /server.php
+
+
+
Notice
+
all usernames and passwords entered on the above form will be written to the web server logs of this server. Use
+ with care.
+
+
Changelog
+
+
2015-05-30: fix problems with generating method payloads for NIL and Undefined parameters
+
2015-04-19: fix problems with LATIN-1 characters in payload
+
2007-02-20: add visual editor for method payload; allow strings, bools as jsonrpc msg id
+
2006-06-26: support building php code stub for calling remote methods
+
2006-05-25: better support for long running queries; check for no-curl installs
+
2006-05-02: added support for JSON-RPC. Note that many interesting json-rpc features are not implemented
+ yet, such as notifications or multicall.
+
+
2006-04-22: added option for setting custom CA certs to verify peer with in SSLmode
+
2006-03-05: added option for setting Basic/Digest/NTLM auth type
+
2006-01-18: added option echoing to screen xmlrpc request before sending it ('More' debug)
+
2005-10-01: added option for setting cookies to be sent to server
+
2005-08-07: added switches for compression of requests and responses and http 1.1
+
2005-06-27: fixed possible security breach in parsing malformed xml
+
2005-06-24: fixed error with calling methods having parameters...
+
+
+
+
diff --git a/php/phpxmlrpc/debugger/common.php b/php/phpxmlrpc/debugger/common.php
new file mode 100644
index 0000000..4026d60
--- /dev/null
+++ b/php/phpxmlrpc/debugger/common.php
@@ -0,0 +1,143 @@
+ 100%...
+ * @todo add support for more options, such as ntlm auth to proxy, or request charset encoding
+ * @todo parse content of payload textarea to be fed to visual editor
+ * @todo add http no-cache headers
+ **/
+
+// make sure we set the correct charset type for output, so that we can display all characters
+header('Content-Type: text/html; charset=utf-8');
+
+include __DIR__ . '/common.php';
+if ($action == '') {
+ $action = 'list';
+}
+
+// relative path to the visual xmlrpc editing dialog
+$editorpath = '../../phpjsrpc/debugger/';
+$editorlibs = '../../phpjsrpc/lib/';
+?>
+
+
+
+ XMLRPC Debugger
+
+
+
+
+
+
+
+
+
+
";
+
+// create parameters from the input array: an xmlrpc array of xmlrpc structs
+$p = array();
+foreach ($inAr as $key => $val) {
+ $p[] = new PhpXmlRpc\Value(
+ array(
+ "name" => new PhpXmlRpc\Value($key),
+ "age" => new PhpXmlRpc\Value($val, "int")
+ ),
+ "struct"
+ );
+}
+$v = new PhpXmlRpc\Value($p, "array");
+print "Encoded into xmlrpc format it looks like this:
\n" . htmlentities($v->serialize()) . "
\n";
+
+// create client and message objects
+$req = new PhpXmlRpc\Request('examples.sortByAge', array($v));
+$client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
+
+// set maximum debug level, to have the complete communication printed to screen
+$client->setDebug(2);
+
+// send request
+print "Now sending request (detailed debug info follows)";
+$resp = $client->send($req);
+
+// check response for errors, and take appropriate action
+if (!$resp->faultCode()) {
+ print "The server gave me these results:
";
+ $value = $resp->value();
+ foreach ($value as $struct) {
+ $name = $struct["name"];
+ $age = $struct["age"];
+ print htmlspecialchars($name->scalarval()) . ", " . htmlspecialchars($age->scalarval()) . "\n";
+ }
+
+ print "For nerds: I got this value back
Query server for available methods and their description
+
The code demonstrates usage of multicall and introspection methods
+faultCode()
+ . " Reason: '" . $r->faultString() . "' ";
+}
+
+$client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
+
+// First off, let's retrieve the list of methods available on the remote server
+print "
methods available at http://" . $client->server . $client->path . "
\n";
+$req = new PhpXmlRpc\Request('system.listMethods');
+$resp = $client->send($req);
+
+if ($resp->faultCode()) {
+ display_error($resp);
+} else {
+ $v = $resp->value();
+
+ // Then, retrieve the signature and help text of each available method
+ foreach ($v as $methodName) {
+ print "
" . $methodName->scalarval() . "
\n";
+ // build messages first, add params later
+ $m1 = new PhpXmlRpc\Request('system.methodHelp');
+ $m2 = new PhpXmlRpc\Request('system.methodSignature');
+ $val = new PhpXmlRpc\Value($methodName->scalarval(), "string");
+ $m1->addParam($val);
+ $m2->addParam($val);
+ // Send multiple requests in one http call.
+ // If server does not support multicall, client will automatically fall back to 2 separate calls
+ $ms = array($m1, $m2);
+ $rs = $client->send($ms);
+ if ($rs[0]->faultCode()) {
+ display_error($rs[0]);
+ } else {
+ $val = $rs[0]->value();
+ $txt = $val->scalarval();
+ if ($txt != "") {
+ print "
This form enables you to send mail via an XML-RPC server.
+ When you press Send this page will reload, showing you the XML-RPC request sent to the host server, the
+ XML-RPC response received and the internal evaluation done by the PHP implementation.
+
+
You can find the source to this page here: mail.php
+ And the source to a functionally identical mail-by-XML-RPC server in the file server.php included with the library (look for the 'mail_send'
+ method)
The code demonstrates usage of some the most automagic client usage possible:
+ 1) client that returns php values instead of xmlrpc value objects
+ 2) wrapping of remote methods into php functions
+ See also proxy.php for an alternative take
+
+return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
+$resp = $client->send(new PhpXmlRpc\Request('system.listMethods'));
+if ($resp->faultCode()) {
+ echo "
Server methods list could not be retrieved: error {$resp->faultCode()} '" . htmlspecialchars($resp->faultString()) . "'
\n";
+} else {
+ echo "
Server methods list retrieved, now wrapping it up...
\n
\n";
+ flush();
+
+ $callable = false;
+ $wrapper = new PhpXmlRpc\Wrapper();
+ foreach ($resp->value() as $methodName) {
+ // $resp->value is an array of strings
+ if ($methodName == 'examples.getStateName') {
+ $callable = $wrapper->wrapXmlrpcMethod($client, $methodName);
+ if ($callable) {
+ echo "
Remote server method " . htmlspecialchars($methodName) . " wrapped into php function
\n";
+ } else {
+ echo "
Remote server method " . htmlspecialchars($methodName) . " could not be wrapped!
\n";
+ }
+ break;
+ }
+ }
+ echo "
\n";
+ flush();
+
+ if ($callable) {
+ echo "Now testing function for remote method to convert U.S. state number into state name";
+ $stateNum = rand(1, 51);
+ // the 2nd parameter gets added to the closure - it is teh debug level to be used for the client
+ $stateName = $callable($stateNum, 2);
+ }
+}
+?>
+
+
diff --git a/php/phpxmlrpc/demo/demo1.xml b/php/phpxmlrpc/demo/demo1.xml
new file mode 100644
index 0000000..eeb6a69
--- /dev/null
+++ b/php/phpxmlrpc/demo/demo1.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+ thearray
+
+
+
+
+ ABCDEFHIJ
+
+
+ 1234
+
+
+ 1
+
+
+
+
+
+
+ theint
+
+ 23
+
+
+
+ thestring
+
+ foobarwhizz
+
+
+
+ thestruct
+
+
+
+ one
+
+ 1
+
+
+
+ two
+
+ 2
+
+
+
+
+
+
+
+
+
+
diff --git a/php/phpxmlrpc/demo/demo2.xml b/php/phpxmlrpc/demo/demo2.xml
new file mode 100644
index 0000000..3289caf
--- /dev/null
+++ b/php/phpxmlrpc/demo/demo2.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ South Dakota's own
+
+
+
+
diff --git a/php/phpxmlrpc/demo/demo3.xml b/php/phpxmlrpc/demo/demo3.xml
new file mode 100644
index 0000000..ed94aab
--- /dev/null
+++ b/php/phpxmlrpc/demo/demo3.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ faultCode
+
+ 4
+
+
+
+ faultString
+
+ Too many parameters.
+
+
+
+
+
+
diff --git a/php/phpxmlrpc/demo/server/discuss.php b/php/phpxmlrpc/demo/server/discuss.php
new file mode 100644
index 0000000..ac65209
--- /dev/null
+++ b/php/phpxmlrpc/demo/server/discuss.php
@@ -0,0 +1,99 @@
+decode($req);
+ $msgID = $n[0];
+ $name = $n[1];
+ $comment = $n[2];
+
+ $dbh = dba_open("/tmp/comments.db", "c", "db2");
+ if ($dbh) {
+ $countID = "${msgID}_count";
+ if (dba_exists($countID, $dbh)) {
+ $count = dba_fetch($countID, $dbh);
+ } else {
+ $count = 0;
+ }
+ // add the new comment in
+ dba_insert($msgID . "_comment_${count}", $comment, $dbh);
+ dba_insert($msgID . "_name_${count}", $name, $dbh);
+ $count++;
+ dba_replace($countID, $count, $dbh);
+ dba_close($dbh);
+ } else {
+ $err = "Unable to open comments database.";
+ }
+ // if we generated an error, create an error return response
+ if ($err) {
+ return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
+ } else {
+ // otherwise, we create the right response
+ return new PhpXmlRpc\Response(new PhpXmlRpc\Value($count, "int"));
+ }
+}
+
+$getComments_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcString));
+
+$getComments_doc = 'Returns an array of comments for a given ID, which
+is the sole argument. Each array item is a struct containing name
+and comment text.';
+
+function getComments($req)
+{
+ $err = "";
+ $ra = array();
+ $encoder = new PhpXmlRpc\Encoder();
+ $msgID = $encoder->decode($req->getParam(0));
+ $dbh = dba_open("/tmp/comments.db", "r", "db2");
+ if ($dbh) {
+ $countID = "${msgID}_count";
+ if (dba_exists($countID, $dbh)) {
+ $count = dba_fetch($countID, $dbh);
+ for ($i = 0; $i < $count; $i++) {
+ $name = dba_fetch("${msgID}_name_${i}", $dbh);
+ $comment = dba_fetch("${msgID}_comment_${i}", $dbh);
+ // push a new struct onto the return array
+ $ra[] = array(
+ "name" => $name,
+ "comment" => $comment,
+ );
+ }
+ }
+ }
+ // if we generated an error, create an error return response
+ if ($err) {
+ return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
+ } else {
+ // otherwise, we create the right response
+ return new PhpXmlRpc\Response($encoder->encode($ra));
+ }
+}
+
+$srv = new PhpXmlRpc\Server(array(
+ "discuss.addComment" => array(
+ "function" => "addComment",
+ "signature" => $addComment_sig,
+ "docstring" => $addComment_doc,
+ ),
+ "discuss.getComments" => array(
+ "function" => "getComments",
+ "signature" => $getComments_sig,
+ "docstring" => $getComments_doc,
+ ),
+));
diff --git a/php/phpxmlrpc/demo/server/proxy.php b/php/phpxmlrpc/demo/server/proxy.php
new file mode 100644
index 0000000..6e791f4
--- /dev/null
+++ b/php/phpxmlrpc/demo/server/proxy.php
@@ -0,0 +1,88 @@
+decode($req->getParam(0));
+ $client = new PhpXmlRpc\Client($url);
+
+ if ($req->getNumParams() > 3) {
+ // we have to set some options onto the client.
+ // Note that if we do not untaint the received values, warnings might be generated...
+ $options = $encoder->decode($req->getParam(3));
+ foreach ($options as $key => $val) {
+ switch ($key) {
+ case 'Cookie':
+ break;
+ case 'Credentials':
+ break;
+ case 'RequestCompression':
+ $client->setRequestCompression($val);
+ break;
+ case 'SSLVerifyHost':
+ $client->setSSLVerifyHost($val);
+ break;
+ case 'SSLVerifyPeer':
+ $client->setSSLVerifyPeer($val);
+ break;
+ case 'Timeout':
+ $timeout = (integer)$val;
+ break;
+ } // switch
+ }
+ }
+
+ // build call for remote server
+ /// @todo find a way to forward client info (such as IP) to server, either
+ /// - as xml comments in the payload, or
+ /// - using std http header conventions, such as X-forwarded-for...
+ $reqMethod = $encoder->decode($req->getParam(1));
+ $pars = $req->getParam(2);
+ $req = new PhpXmlRpc\Request($reqMethod);
+ foreach ($pars as $par) {
+ $req->addParam($par);
+ }
+
+ // add debug info into response we give back to caller
+ PhpXmlRpc\Server::xmlrpc_debugmsg("Sending to server $url the payload: " . $req->serialize());
+
+ return $client->send($req, $timeout);
+}
+
+// run the server
+$server = new PhpXmlRpc\Server(
+ array(
+ 'xmlrpcproxy.call' => array(
+ 'function' => 'forward_request',
+ 'signature' => array(
+ array('mixed', 'string', 'string', 'array'),
+ array('mixed', 'string', 'string', 'array', 'struct'),
+ ),
+ 'docstring' => 'forwards xmlrpc calls to remote servers. Returns remote method\'s response. Accepts params: remote server url (might include basic auth credentials), method name, array of params, and (optionally) a struct containing call options',
+ ),
+ )
+);
diff --git a/php/phpxmlrpc/demo/server/server.php b/php/phpxmlrpc/demo/server/server.php
new file mode 100644
index 0000000..b18cf46
--- /dev/null
+++ b/php/phpxmlrpc/demo/server/server.php
@@ -0,0 +1,981 @@
+hello = 'world';
+ return $obj;
+ }
+}
+
+// a PHP version of the state-number server
+// send me an integer and i'll sell you a state
+
+$stateNames = array(
+ "Alabama", "Alaska", "Arizona", "Arkansas", "California",
+ "Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
+ "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
+ "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
+ "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
+ "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
+ "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
+ "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
+ "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming",
+);
+
+$findstate_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcInt));
+$findstate_doc = 'When passed an integer between 1 and 51 returns the
+name of a US state, where the integer is the index of that state name
+in an alphabetic order.';
+
+function findState($req)
+{
+ global $stateNames;
+
+ $err = "";
+ // get the first param
+ $sno = $req->getParam(0);
+
+ // param must be there and of the correct type: server object does the validation for us
+
+ // extract the value of the state number
+ $snv = $sno->scalarval();
+ // look it up in our array (zero-based)
+ if (isset($stateNames[$snv - 1])) {
+ $stateName = $stateNames[$snv - 1];
+ } else {
+ // not there, so complain
+ $err = "I don't have a state for the index '" . $snv . "'";
+ }
+
+ // if we generated an error, create an error return response
+ if ($err) {
+ return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
+ } else {
+ // otherwise, we create the right response with the state name
+ return new PhpXmlRpc\Response(new Value($stateName));
+ }
+}
+
+/**
+ * Inner code of the state-number server.
+ * Used to test wrapping of PHP functions into xmlrpc methods.
+ *
+ * @param integer $stateNo the state number
+ *
+ * @return string the name of the state (or error description)
+ *
+ * @throws Exception if state is not found
+ */
+function inner_findstate($stateNo)
+{
+ global $stateNames;
+
+ if (isset($stateNames[$stateNo - 1])) {
+ return $stateNames[$stateNo - 1];
+ } else {
+ // not, there so complain
+ throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser);
+ }
+}
+
+$wrapper = new PhpXmlRpc\Wrapper();
+
+$findstate2_sig = $wrapper->wrapPhpFunction('inner_findstate');
+
+$findstate3_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState'));
+
+$obj = new xmlrpcServerMethodsContainer();
+$findstate4_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate'));
+
+$findstate5_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
+eval($findstate5_sig['source']);
+
+$findstate6_sig = $wrapper->wrapPhpFunction('inner_findstate', '', array('return_source' => true));
+eval($findstate6_sig['source']);
+
+$findstate7_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState'), '', array('return_source' => true));
+eval($findstate7_sig['source']);
+
+$obj = new xmlrpcServerMethodsContainer();
+$findstate8_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate'), '', array('return_source' => true));
+eval($findstate8_sig['source']);
+
+$findstate9_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
+eval($findstate9_sig['source']);
+
+$findstate10_sig = array(
+ "function" => function ($req) { return findState($req); },
+ "signature" => $findstate_sig,
+ "docstring" => $findstate_doc,
+);
+
+$findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return inner_findstate($stateNo); });
+
+$c = new xmlrpcServerMethodsContainer;
+$moreSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'tests.', 'method_type' => 'all'));
+
+$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true));
+
+// used to test signatures with NULL params
+$findstate12_sig = array(
+ array(Value::$xmlrpcString, Value::$xmlrpcInt, Value::$xmlrpcNull),
+ array(Value::$xmlrpcString, Value::$xmlrpcNull, Value::$xmlrpcInt),
+);
+
+function findStateWithNulls($req)
+{
+ $a = $req->getParam(0);
+ $b = $req->getParam(1);
+
+ if ($a->scalartyp() == Value::$xmlrpcNull)
+ return new PhpXmlRpc\Response(new Value(inner_findstate($b->scalarval())));
+ else
+ return new PhpXmlRpc\Response(new Value(inner_findstate($a->scalarval())));
+}
+
+$addtwo_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt, Value::$xmlrpcInt));
+$addtwo_doc = 'Add two integers together and return the result';
+function addTwo($req)
+{
+ $s = $req->getParam(0);
+ $t = $req->getParam(1);
+
+ return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcInt));
+}
+
+$addtwodouble_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble, Value::$xmlrpcDouble));
+$addtwodouble_doc = 'Add two doubles together and return the result';
+function addTwoDouble($req)
+{
+ $s = $req->getParam(0);
+ $t = $req->getParam(1);
+
+ return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcDouble));
+}
+
+$stringecho_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
+$stringecho_doc = 'Accepts a string parameter, returns the string.';
+function stringEcho($req)
+{
+ // just sends back a string
+ return new PhpXmlRpc\Response(new Value($req->getParam(0)->scalarval()));
+}
+
+$echoback_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
+$echoback_doc = 'Accepts a string parameter, returns the entire incoming payload';
+function echoBack($req)
+{
+ // just sends back a string with what i got sent to me, just escaped, that's all
+ $s = "I got the following message:\n" . $req->serialize();
+
+ return new PhpXmlRpc\Response(new Value($s));
+}
+
+$echosixtyfour_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcBase64));
+$echosixtyfour_doc = 'Accepts a base64 parameter and returns it decoded as a string';
+function echoSixtyFour($req)
+{
+ // Accepts an encoded value, but sends it back as a normal string.
+ // This is to test that base64 encoding is working as expected
+ $incoming = $req->getParam(0);
+
+ return new PhpXmlRpc\Response(new Value($incoming->scalarval(), Value::$xmlrpcString));
+}
+
+$bitflipper_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
+function bitFlipper($req)
+{
+ $v = $req->getParam(0);
+ $rv = new Value(array(), Value::$xmlrpcArray);
+
+ foreach ($v as $b) {
+ if ($b->scalarval()) {
+ $rv[] = new Value(false, Value::$xmlrpcBoolean);
+ } else {
+ $rv[] = new Value(true, Value::$xmlrpcBoolean);
+ }
+ }
+
+ return new PhpXmlRpc\Response($rv);
+}
+
+// Sorting demo
+//
+// send me an array of structs thus:
+//
+// Dave 35
+// Edd 45
+// Fred 23
+// Barney 37
+//
+// and I'll return it to you in sorted order
+
+function agesorter_compare($a, $b)
+{
+ global $agesorter_arr;
+
+ // don't even ask me _why_ these come padded with hyphens, I couldn't tell you :p
+ $a = str_replace("-", "", $a);
+ $b = str_replace("-", "", $b);
+
+ if ($agesorter_arr[$a] == $agesorter_arr[$b]) {
+ return 0;
+ }
+
+ return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
+}
+
+$agesorter_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$agesorter_doc = 'Send this method an array of [string, int] structs, eg:
+
+ Dave 35
+ Edd 45
+ Fred 23
+ Barney 37
+
+And the array will be returned with the entries sorted by their numbers.
+';
+function ageSorter($req)
+{
+ global $agesorter_arr, $s;
+
+ PhpXmlRpc\Server::xmlrpc_debugmsg("Entering 'agesorter'");
+ // get the parameter
+ $sno = $req->getParam(0);
+ // error string for [if|when] things go wrong
+ $err = "";
+ $agar = array();
+
+ $max = $sno->count();
+ PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
+ foreach ($sno as $i => $rec) {
+ if ($rec->kindOf() != "struct") {
+ $err = "Found non-struct in array at element $i";
+ break;
+ }
+ // extract name and age from struct
+ $n = $rec["name"];
+ $a = $rec["age"];
+ // $n and $a are xmlrpcvals,
+ // so get the scalarval from them
+ $agar[$n->scalarval()] = $a->scalarval();
+ }
+
+ // create the output value
+ $v = new Value(array(), Value::$xmlrpcArray);
+
+ $agesorter_arr = $agar;
+ // hack, must make global as uksort() won't
+ // allow us to pass any other auxiliary information
+ uksort($agesorter_arr, 'agesorter_compare');
+ while (list($key, $val) = each($agesorter_arr)) {
+ // recreate each struct element
+ $v[] = new Value(
+ array(
+ "name" => new Value($key),
+ "age" => new Value($val, "int")
+ ),
+ Value::$xmlrpcStruct
+ );
+ }
+
+ if ($err) {
+ return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
+ } else {
+ return new PhpXmlRpc\Response($v);
+ }
+}
+
+// signature and instructions, place these in the dispatch map
+$mailsend_sig = array(array(
+ Value::$xmlrpcBoolean, Value::$xmlrpcString, Value::$xmlrpcString,
+ Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString,
+ Value::$xmlrpcString, Value::$xmlrpcString,
+));
+$mailsend_doc = 'mail.send(recipient, subject, text, sender, cc, bcc, mimetype)
+recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.
+subject is a string, the subject of the message.
+sender is a string, it\'s the email address of the person sending the message. This string can not be
+a comma-separated list, it must contain a single email address only.
+text is a string, it contains the body of the message.
+mimetype, a string, is a standard MIME type, for example, text/plain.
+';
+// WARNING; this functionality depends on the sendmail -t option
+// it may not work with Windows machines properly; particularly
+// the Bcc option. Sneak on your friends at your own risk!
+function mailSend($req)
+{
+ $err = "";
+
+ $mTo = $req->getParam(0);
+ $mSub = $req->getParam(1);
+ $mBody = $req->getParam(2);
+ $mFrom = $req->getParam(3);
+ $mCc = $req->getParam(4);
+ $mBcc = $req->getParam(5);
+ $mMime = $req->getParam(6);
+
+ if ($mTo->scalarval() == "") {
+ $err = "Error, no 'To' field specified";
+ }
+
+ if ($mFrom->scalarval() == "") {
+ $err = "Error, no 'From' field specified";
+ }
+
+ $msgHdr = "From: " . $mFrom->scalarval() . "\n";
+ $msgHdr .= "To: " . $mTo->scalarval() . "\n";
+
+ if ($mCc->scalarval() != "") {
+ $msgHdr .= "Cc: " . $mCc->scalarval() . "\n";
+ }
+ if ($mBcc->scalarval() != "") {
+ $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n";
+ }
+ if ($mMime->scalarval() != "") {
+ $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n";
+ }
+ $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0";
+
+ if ($err == "") {
+ if (!mail("",
+ $mSub->scalarval(),
+ $mBody->scalarval(),
+ $msgHdr)
+ ) {
+ $err = "Error, could not send the mail.";
+ }
+ }
+
+ if ($err) {
+ return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
+ } else {
+ return new PhpXmlRpc\Response(new Value(true, Value::$xmlrpcBoolean));
+ }
+}
+
+$getallheaders_sig = array(array(Value::$xmlrpcStruct));
+$getallheaders_doc = 'Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
+function getAllHeaders_xmlrpc($req)
+{
+ $encoder = new PhpXmlRpc\Encoder();
+
+ if (function_exists('getallheaders')) {
+ return new PhpXmlRpc\Response($encoder->encode(getallheaders()));
+ } else {
+ $headers = array();
+ // IIS: poor man's version of getallheaders
+ foreach ($_SERVER as $key => $val) {
+ if (strpos($key, 'HTTP_') === 0) {
+ $key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
+ $headers[$key] = $val;
+ }
+ }
+
+ return new PhpXmlRpc\Response($encoder->encode($headers));
+ }
+}
+
+$setcookies_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
+$setcookies_doc = 'Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
+function setCookies($req)
+{
+ $encoder = new PhpXmlRpc\Encoder();
+ $cookies = $req->getParam(0);
+ foreach ($cookies as $name => $value) {
+ $cookieDesc = $encoder->decode($value);
+ setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
+ }
+
+ return new PhpXmlRpc\Response(new Value(1, Value::$xmlrpcInt));
+}
+
+$getcookies_sig = array(array(Value::$xmlrpcStruct));
+$getcookies_doc = 'Sends to client a response containing all http cookies as received in the request (as struct)';
+function getCookies($req)
+{
+ $encoder = new PhpXmlRpc\Encoder();
+ return new PhpXmlRpc\Response($encoder->encode($_COOKIE));
+}
+
+$v1_arrayOfStructs_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcArray));
+$v1_arrayOfStructs_doc = 'This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all s. Your handler must add all the struct elements named curly and return the result.';
+function v1_arrayOfStructs($req)
+{
+ $sno = $req->getParam(0);
+ $numCurly = 0;
+ foreach ($sno as $str) {
+ foreach ($str as $key => $val) {
+ if ($key == "curly") {
+ $numCurly += $val->scalarval();
+ }
+ }
+ }
+
+ return new PhpXmlRpc\Response(new Value($numCurly, Value::$xmlrpcInt));
+}
+
+$v1_easyStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
+$v1_easyStruct_doc = 'This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all <i4>s. Your handler must add the three numbers and return the result.';
+function v1_easyStruct($req)
+{
+ $sno = $req->getParam(0);
+ $moe = $sno["moe"];
+ $larry = $sno["larry"];
+ $curly = $sno["curly"];
+ $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval();
+
+ return new PhpXmlRpc\Response(new Value($num, Value::$xmlrpcInt));
+}
+
+$v1_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
+$v1_echoStruct_doc = 'This handler takes a single parameter, a struct. Your handler must return the struct.';
+function v1_echoStruct($req)
+{
+ $sno = $req->getParam(0);
+
+ return new PhpXmlRpc\Response($sno);
+}
+
+$v1_manyTypes_sig = array(array(
+ Value::$xmlrpcArray, Value::$xmlrpcInt, Value::$xmlrpcBoolean,
+ Value::$xmlrpcString, Value::$xmlrpcDouble, Value::$xmlrpcDateTime,
+ Value::$xmlrpcBase64,
+));
+$v1_manyTypes_doc = 'This handler takes six parameters, and returns an array containing all the parameters.';
+function v1_manyTypes($req)
+{
+ return new PhpXmlRpc\Response(new Value(
+ array(
+ $req->getParam(0),
+ $req->getParam(1),
+ $req->getParam(2),
+ $req->getParam(3),
+ $req->getParam(4),
+ $req->getParam(5)
+ ),
+ Value::$xmlrpcArray
+ ));
+}
+
+$v1_moderateSizeArrayCheck_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcArray));
+$v1_moderateSizeArrayCheck_doc = 'This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
+function v1_moderateSizeArrayCheck($req)
+{
+ $ar = $req->getParam(0);
+ $sz = $ar->count();
+ $first = $ar[0];
+ $last = $ar[$sz - 1];
+
+ return new PhpXmlRpc\Response(new Value($first->scalarval() .
+ $last->scalarval(), Value::$xmlrpcString));
+}
+
+$v1_simpleStructReturn_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcInt));
+$v1_simpleStructReturn_doc = 'This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
+function v1_simpleStructReturn($req)
+{
+ $sno = $req->getParam(0);
+ $v = $sno->scalarval();
+
+ return new PhpXmlRpc\Response(new Value(
+ array(
+ "times10" => new Value($v * 10, Value::$xmlrpcInt),
+ "times100" => new Value($v * 100, Value::$xmlrpcInt),
+ "times1000" => new Value($v * 1000, Value::$xmlrpcInt)
+ ),
+ Value::$xmlrpcStruct
+ ));
+}
+
+$v1_nestedStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
+$v1_nestedStruct_doc = 'This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all <i4>s. Your handler must add the three numbers and return the result.';
+function v1_nestedStruct($req)
+{
+ $sno = $req->getParam(0);
+
+ $twoK = $sno["2000"];
+ $april = $twoK["04"];
+ $fools = $april["01"];
+ $curly = $fools["curly"];
+ $larry = $fools["larry"];
+ $moe = $fools["moe"];
+
+ return new PhpXmlRpc\Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), Value::$xmlrpcInt));
+}
+
+$v1_countTheEntities_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcString));
+$v1_countTheEntities_doc = 'This handler takes a single parameter, a string, that contains any number of predefined entities, namely <, >, & \' and ". Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
+function v1_countTheEntities($req)
+{
+ $sno = $req->getParam(0);
+ $str = $sno->scalarval();
+ $gt = 0;
+ $lt = 0;
+ $ap = 0;
+ $qu = 0;
+ $amp = 0;
+ for ($i = 0; $i < strlen($str); $i++) {
+ $c = substr($str, $i, 1);
+ switch ($c) {
+ case ">":
+ $gt++;
+ break;
+ case "<":
+ $lt++;
+ break;
+ case "\"":
+ $qu++;
+ break;
+ case "'":
+ $ap++;
+ break;
+ case "&":
+ $amp++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return new PhpXmlRpc\Response(new Value(
+ array(
+ "ctLeftAngleBrackets" => new Value($lt, Value::$xmlrpcInt),
+ "ctRightAngleBrackets" => new Value($gt, Value::$xmlrpcInt),
+ "ctAmpersands" => new Value($amp, Value::$xmlrpcInt),
+ "ctApostrophes" => new Value($ap, Value::$xmlrpcInt),
+ "ctQuotes" => new Value($qu, Value::$xmlrpcInt)
+ ),
+ Value::$xmlrpcStruct
+ ));
+}
+
+// trivial interop tests
+// http://www.xmlrpc.com/stories/storyReader$1636
+
+$i_echoString_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
+$i_echoString_doc = "Echoes string.";
+
+$i_echoStringArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$i_echoStringArray_doc = "Echoes string array.";
+
+$i_echoInteger_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt));
+$i_echoInteger_doc = "Echoes integer.";
+
+$i_echoIntegerArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$i_echoIntegerArray_doc = "Echoes integer array.";
+
+$i_echoFloat_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble));
+$i_echoFloat_doc = "Echoes float.";
+
+$i_echoFloatArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$i_echoFloatArray_doc = "Echoes float array.";
+
+$i_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
+$i_echoStruct_doc = "Echoes struct.";
+
+$i_echoStructArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
+$i_echoStructArray_doc = "Echoes struct array.";
+
+$i_echoValue_doc = "Echoes any value back.";
+$i_echoValue_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
+
+$i_echoBase64_sig = array(array(Value::$xmlrpcBase64, Value::$xmlrpcBase64));
+$i_echoBase64_doc = "Echoes base64.";
+
+$i_echoDate_sig = array(array(Value::$xmlrpcDateTime, Value::$xmlrpcDateTime));
+$i_echoDate_doc = "Echoes dateTime.";
+
+function i_echoParam($req)
+{
+ $s = $req->getParam(0);
+
+ return new PhpXmlRpc\Response($s);
+}
+
+function i_echoString($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoInteger($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoFloat($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoStruct($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoStringArray($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoIntegerArray($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoFloatArray($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoStructArray($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoValue($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoBase64($req)
+{
+ return i_echoParam($req);
+}
+
+function i_echoDate($req)
+{
+ return i_echoParam($req);
+}
+
+$i_whichToolkit_sig = array(array(Value::$xmlrpcStruct));
+$i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
+
+function i_whichToolkit($req)
+{
+ global $SERVER_SOFTWARE;
+ $ret = array(
+ "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
+ "toolkitName" => PhpXmlRpc\PhpXmlRpc::$xmlrpcName,
+ "toolkitVersion" => PhpXmlRpc\PhpXmlRpc::$xmlrpcVersion,
+ "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE'],
+ );
+
+ $encoder = new PhpXmlRpc\Encoder();
+ return new PhpXmlRpc\Response($encoder->encode($ret));
+}
+
+$object = new xmlrpcServerMethodsContainer();
+$signatures = array(
+ "examples.getStateName" => array(
+ "function" => "findState",
+ "signature" => $findstate_sig,
+ "docstring" => $findstate_doc,
+ ),
+ "examples.sortByAge" => array(
+ "function" => "ageSorter",
+ "signature" => $agesorter_sig,
+ "docstring" => $agesorter_doc,
+ ),
+ "examples.addtwo" => array(
+ "function" => "addTwo",
+ "signature" => $addtwo_sig,
+ "docstring" => $addtwo_doc,
+ ),
+ "examples.addtwodouble" => array(
+ "function" => "addTwoDouble",
+ "signature" => $addtwodouble_sig,
+ "docstring" => $addtwodouble_doc,
+ ),
+ "examples.stringecho" => array(
+ "function" => "stringEcho",
+ "signature" => $stringecho_sig,
+ "docstring" => $stringecho_doc,
+ ),
+ "examples.echo" => array(
+ "function" => "echoBack",
+ "signature" => $echoback_sig,
+ "docstring" => $echoback_doc,
+ ),
+ "examples.decode64" => array(
+ "function" => "echoSixtyFour",
+ "signature" => $echosixtyfour_sig,
+ "docstring" => $echosixtyfour_doc,
+ ),
+ "examples.invertBooleans" => array(
+ "function" => "bitFlipper",
+ "signature" => $bitflipper_sig,
+ "docstring" => $bitflipper_doc,
+ ),
+ // signature omitted on purpose
+ "tests.generatePHPWarning" => array(
+ "function" => array($object, "phpWarningGenerator"),
+ ),
+ // signature omitted on purpose
+ "tests.raiseException" => array(
+ "function" => array($object, "exceptionGenerator"),
+ ),
+ // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
+ // NB: we can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
+ "tests.utf8methodname." . 'κόÏμε' => array(
+ "function" => "stringEcho",
+ "signature" => $stringecho_sig,
+ "docstring" => $stringecho_doc,
+ ),
+ /*"tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
+ "function" => "stringEcho",
+ "signature" => $stringecho_sig,
+ "docstring" => $stringecho_doc,
+ ),*/
+ "examples.getallheaders" => array(
+ "function" => 'getAllHeaders_xmlrpc',
+ "signature" => $getallheaders_sig,
+ "docstring" => $getallheaders_doc,
+ ),
+ "examples.setcookies" => array(
+ "function" => 'setCookies',
+ "signature" => $setcookies_sig,
+ "docstring" => $setcookies_doc,
+ ),
+ "examples.getcookies" => array(
+ "function" => 'getCookies',
+ "signature" => $getcookies_sig,
+ "docstring" => $getcookies_doc,
+ ),
+ "mail.send" => array(
+ "function" => "mailSend",
+ "signature" => $mailsend_sig,
+ "docstring" => $mailsend_doc,
+ ),
+ "validator1.arrayOfStructsTest" => array(
+ "function" => "v1_arrayOfStructs",
+ "signature" => $v1_arrayOfStructs_sig,
+ "docstring" => $v1_arrayOfStructs_doc,
+ ),
+ "validator1.easyStructTest" => array(
+ "function" => "v1_easyStruct",
+ "signature" => $v1_easyStruct_sig,
+ "docstring" => $v1_easyStruct_doc,
+ ),
+ "validator1.echoStructTest" => array(
+ "function" => "v1_echoStruct",
+ "signature" => $v1_echoStruct_sig,
+ "docstring" => $v1_echoStruct_doc,
+ ),
+ "validator1.manyTypesTest" => array(
+ "function" => "v1_manyTypes",
+ "signature" => $v1_manyTypes_sig,
+ "docstring" => $v1_manyTypes_doc,
+ ),
+ "validator1.moderateSizeArrayCheck" => array(
+ "function" => "v1_moderateSizeArrayCheck",
+ "signature" => $v1_moderateSizeArrayCheck_sig,
+ "docstring" => $v1_moderateSizeArrayCheck_doc,
+ ),
+ "validator1.simpleStructReturnTest" => array(
+ "function" => "v1_simpleStructReturn",
+ "signature" => $v1_simpleStructReturn_sig,
+ "docstring" => $v1_simpleStructReturn_doc,
+ ),
+ "validator1.nestedStructTest" => array(
+ "function" => "v1_nestedStruct",
+ "signature" => $v1_nestedStruct_sig,
+ "docstring" => $v1_nestedStruct_doc,
+ ),
+ "validator1.countTheEntities" => array(
+ "function" => "v1_countTheEntities",
+ "signature" => $v1_countTheEntities_sig,
+ "docstring" => $v1_countTheEntities_doc,
+ ),
+ "interopEchoTests.echoString" => array(
+ "function" => "i_echoString",
+ "signature" => $i_echoString_sig,
+ "docstring" => $i_echoString_doc,
+ ),
+ "interopEchoTests.echoStringArray" => array(
+ "function" => "i_echoStringArray",
+ "signature" => $i_echoStringArray_sig,
+ "docstring" => $i_echoStringArray_doc,
+ ),
+ "interopEchoTests.echoInteger" => array(
+ "function" => "i_echoInteger",
+ "signature" => $i_echoInteger_sig,
+ "docstring" => $i_echoInteger_doc,
+ ),
+ "interopEchoTests.echoIntegerArray" => array(
+ "function" => "i_echoIntegerArray",
+ "signature" => $i_echoIntegerArray_sig,
+ "docstring" => $i_echoIntegerArray_doc,
+ ),
+ "interopEchoTests.echoFloat" => array(
+ "function" => "i_echoFloat",
+ "signature" => $i_echoFloat_sig,
+ "docstring" => $i_echoFloat_doc,
+ ),
+ "interopEchoTests.echoFloatArray" => array(
+ "function" => "i_echoFloatArray",
+ "signature" => $i_echoFloatArray_sig,
+ "docstring" => $i_echoFloatArray_doc,
+ ),
+ "interopEchoTests.echoStruct" => array(
+ "function" => "i_echoStruct",
+ "signature" => $i_echoStruct_sig,
+ "docstring" => $i_echoStruct_doc,
+ ),
+ "interopEchoTests.echoStructArray" => array(
+ "function" => "i_echoStructArray",
+ "signature" => $i_echoStructArray_sig,
+ "docstring" => $i_echoStructArray_doc,
+ ),
+ "interopEchoTests.echoValue" => array(
+ "function" => "i_echoValue",
+ "signature" => $i_echoValue_sig,
+ "docstring" => $i_echoValue_doc,
+ ),
+ "interopEchoTests.echoBase64" => array(
+ "function" => "i_echoBase64",
+ "signature" => $i_echoBase64_sig,
+ "docstring" => $i_echoBase64_doc,
+ ),
+ "interopEchoTests.echoDate" => array(
+ "function" => "i_echoDate",
+ "signature" => $i_echoDate_sig,
+ "docstring" => $i_echoDate_doc,
+ ),
+ "interopEchoTests.whichToolkit" => array(
+ "function" => "i_whichToolkit",
+ "signature" => $i_whichToolkit_sig,
+ "docstring" => $i_whichToolkit_doc,
+ ),
+
+ 'tests.getStateName.2' => $findstate2_sig,
+ 'tests.getStateName.3' => $findstate3_sig,
+ 'tests.getStateName.4' => $findstate4_sig,
+ 'tests.getStateName.5' => $findstate5_sig,
+ 'tests.getStateName.6' => $findstate6_sig,
+ 'tests.getStateName.7' => $findstate7_sig,
+ 'tests.getStateName.8' => $findstate8_sig,
+ 'tests.getStateName.9' => $findstate9_sig,
+ 'tests.getStateName.10' => $findstate10_sig,
+ 'tests.getStateName.11' => $findstate11_sig,
+
+ 'tests.getStateName.12' => array(
+ "function" => "findStateWithNulls",
+ "signature" => $findstate12_sig,
+ "docstring" => $findstate_doc,
+ ),
+
+ 'tests.returnPhpObject' => $returnObj_sig,
+);
+
+$signatures = array_merge($signatures, $moreSignatures);
+
+// enable support for the NULL extension
+PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true;
+
+$s = new PhpXmlRpc\Server($signatures, false);
+$s->setdebug(3);
+$s->compress_response = true;
+
+// out-of-band information: let the client manipulate the server operations.
+// we do this to help the testsuite script: do not reproduce in production!
+if (isset($_GET['RESPONSE_ENCODING'])) {
+ $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
+}
+if (isset($_GET['DETECT_ENCODINGS'])) {
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_detectencodings = $_GET['DETECT_ENCODINGS'];
+}
+if (isset($_GET['EXCEPTION_HANDLING'])) {
+ $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
+}
+$s->service();
+// that should do all we need!
+
+// out-of-band information: let the client manipulate the server operations.
+// we do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+ include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
+}
diff --git a/php/phpxmlrpc/demo/vardemo.php b/php/phpxmlrpc/demo/vardemo.php
new file mode 100644
index 0000000..3c9812a
--- /dev/null
+++ b/php/phpxmlrpc/demo/vardemo.php
@@ -0,0 +1,95 @@
+
+xmlrpc
+
+Testing value serialization\n";
+
+$v = new PhpXmlRpc\Value(23, "int");
+print "
" . htmlentities($v->serialize()) . "
";
+$v = new PhpXmlRpc\Value("What are you saying? >> << &&");
+print "
" . htmlentities($v->serialize()) . "
";
+
+$v = new PhpXmlRpc\Value(
+ array(
+ new PhpXmlRpc\Value("ABCDEFHIJ"),
+ new PhpXmlRpc\Value(1234, 'int'),
+ new PhpXmlRpc\Value(1, 'boolean'),
+ ),
+ "array"
+);
+
+print "
" . htmlentities($v->serialize()) . "
";
+
+$v = new PhpXmlRpc\Value(
+ array(
+ "thearray" => new PhpXmlRpc\Value(
+ array(
+ new PhpXmlRpc\Value("ABCDEFHIJ"),
+ new PhpXmlRpc\Value(1234, 'int'),
+ new PhpXmlRpc\Value(1, 'boolean'),
+ new PhpXmlRpc\Value(0, 'boolean'),
+ new PhpXmlRpc\Value(true, 'boolean'),
+ new PhpXmlRpc\Value(false, 'boolean'),
+ ),
+ "array"
+ ),
+ "theint" => new PhpXmlRpc\Value(23, 'int'),
+ "thestring" => new PhpXmlRpc\Value("foobarwhizz"),
+ "thestruct" => new PhpXmlRpc\Value(
+ array(
+ "one" => new PhpXmlRpc\Value(1, 'int'),
+ "two" => new PhpXmlRpc\Value(2, 'int'),
+ ),
+ "struct"
+ ),
+ ),
+ "struct"
+);
+
+print "
" . htmlentities($v->serialize()) . "
";
+
+$w = new PhpXmlRpc\Value(array($v, new PhpXmlRpc\Value("That was the struct!")), "array");
+
+print "
" . htmlentities($w->serialize()) . "
";
+
+$w = new PhpXmlRpc\Value("Mary had a little lamb,
+Whose fleece was white as snow,
+And everywhere that Mary went
+the lamb was sure to go.
+
+Mary had a little lamb
+She tied it to a pylon
+Ten thousand volts went down its back
+And turned it into nylon", "base64"
+);
+print "
" . htmlentities($w->serialize()) . "
";
+print "
Value of base64 string is: '" . $w->scalarval() . "'
\n";
+
+$t = time();
+$date = PhpXmlRpc\Helper\Date::iso8601Encode($t);
+print "Now is $t --> $date\n";
+print "Or in UTC, that is " . PhpXmlRpc\Helper\Date::iso8601Encode($t, 1) . "\n";
+$tb = PhpXmlRpc\Helper\Date::iso8601Decode($date);
+print "That is to say $date --> $tb\n";
+print "Which comes out at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb) . "\n";
+print "Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($date, 1) . "\n";
+
+print "
\n";
+ } else {
+ print "Fault ";
+ print "Code: " . htmlentities($r->faultCode()) . " " .
+ "Reason: '" . htmlentities($r->faultString()) . "' ";
+ }
+
+----
+
+=== Executing a multicall call
+
+To be documented...
+
+
+[[faq]]
+
+[qanda]
+== Frequently Asked Questions
+
+==== How to send custom XML as payload of a method call::
+
+Unfortunately, at the time the XML-RPC spec was designed, support
+ for namespaces in XML was not as ubiquitous as it is now. As a
+ consequence, no support was provided in the protocol for embedding XML
+ elements from other namespaces into an xmlrpc request.
+
+To send an XML "chunk" as payload of a method call or response,
+ two options are available: either send the complete XML block as a
+ string xmlrpc value, or as a base64 value. Since the '<' character in
+ string values is encoded as '<' in the xml payload of the method
+ call, the XML string will not break the surrounding xmlrpc, unless
+ characters outside of the assumed character set are used. The second
+ method has the added benefits of working independently of the charset
+ encoding used for the xml to be transmitted, and preserving exactly
+ whitespace, whilst incurring in some extra message length and cpu load
+ (for carrying out the base64 encoding/decoding).
+
+
+==== Is there any limitation on the size of the requests / responses that can be successfully sent?::
+
+Yes. But I have no hard figure to give; it most likely will depend
+ on the version of PHP in usage and its configuration.
+
+Keep in mind that this library is not optimized for speed nor for
+ memory usage. Better alternatives exist when there are strict
+ requirements on throughput or resource usage, such as the php native
+ xmlrpc extension (see the PHP manual for more information).
+
+Keep in mind also that HTTP is probably not the best choice in
+ such a situation, and XML is a deadly enemy. CSV formatted data over
+ socket would be much more efficient.
+
+If you really need to move a massive amount of data around, and
+ you are crazy enough to do it using phpxmlrpc, your best bet is to
+ bypass usage of the xmlrpcval objects, at least in the decoding phase,
+ and have the server (or client) object return to the calling function
+ directly php values (see xmlrpc_client::return_type
+ and xmlrpc_server::functions_parameters_type for more
+ details).
+
+
+==== My server (client) returns an error whenever the client (server) returns accented characters
+
+To be documented...
+
+
+==== How to enable long-lasting method calls
+
+To be documented...
+
+
+==== My client returns "XML-RPC Fault #2: Invalid return payload: enable debugging to examine incoming payload": what should I do?
+
+The response you are seeing is a default error response that the
+ client object returns to the php application when the server did not
+ respond to the call with a valid xmlrpc response.
+
+The most likely cause is that you are not using the correct URL
+ when creating the client object, or you do not have appropriate access
+ rights to the web page you are requesting, or some other common http
+ misconfiguration.
+
+To find out what the server is really returning to your client,
+ you have to enable the debug mode of the client, using
+ $client->setdebug(1);
+
+
+==== How can I save to a file the xml of the xmlrpc responses received from servers?
+
+If what you need is to save the responses received from the server
+ as xml, you have two options:
+
+1- use the serialize() method on the response object.
+
+
+[source, php]
+----
+
+$resp = $client->send($msg);
+if (!$resp->faultCode())
+ $data_to_be_saved = $resp->serialize();
+
+----
+
+Note that this will not be 100% accurate, since the xml generated
+ by the response object can be different from the xml received,
+ especially if there is some character set conversion involved, or such
+ (eg. if you receive an empty string tag as , serialize()
+ will output ), or if the server sent back
+ as response something invalid (in which case the xml generated client
+ side using serialize() will correspond to the error response generated
+ internally by the lib).
+
+2 - set the client object to return the raw xml received instead
+ of the decoded objects:
+
+
+[source, php]
+----
+
+$client = new xmlrpc_client($url);
+$client->return_type = 'xml';
+$resp = $client->send($msg);
+if (!$resp->faultCode())
+ $data_to_be_saved = $resp->value();
+
+----
+
+Note that using this method the xml response response will not be
+ parsed at all by the library, only the http communication protocol will
+ be checked. This means that xmlrpc responses sent by the server that
+ would have generated an error response on the client (eg. malformed xml,
+ responses that have faultcode set, etc...) now will not be flagged as
+ invalid, and you might end up saving not valid xml but random
+ junk...
+
+
+==== Can I use the ms windows character set?
+
+If the data your application is using comes from a Microsoft
+ application, there are some chances that the character set used to
+ encode it is CP1252 (the same might apply to data received from an
+ external xmlrpc server/client, but it is quite rare to find xmlrpc
+ toolkits that encode to CP1252 instead of UTF8). It is a character set
+ which is "almost" compatible with ISO 8859-1, but for a few extra
+ characters.
+
+PHP-XMLRPC only supports the ISO 8859-1 and UTF8 character sets.
+ The net result of this situation is that those extra characters will not
+ be properly encoded, and will be received at the other end of the
+ XML-RPC transmission as "garbled data". Unfortunately the library cannot
+ provide real support for CP1252 because of limitations in the PHP 4 xml
+ parser. Luckily, we tried our best to support this character set anyway,
+ and, since version 2.2.1, there is some form of support, left commented
+ in the code.
+
+To properly encode outgoing data that is natively in CP1252, you
+ will have to uncomment all relative code in the file
+ __xmlrpc.inc__ (you can search for the string "1252"),
+ then set ++$$$GLOBALS['xmlrpc_internalencoding']='CP1252';$$++
+ Please note that all incoming data will then be fed to your application
+ as UTF-8 to avoid any potential data loss.
+
+
+==== Does the library support using cookies / http sessions?
+
+In short: yes, but a little coding is needed to make it
+ happen.
+
+The code below uses sessions to e.g. let the client store a value
+ on the server and retrieve it later.
+
+[source, php]
+----
+
+$resp = $client->send(new xmlrpcmsg('registervalue', array(new xmlrpcval('foo'), new xmlrpcval('bar'))));
+if (!$resp->faultCode())
+{
+ $cookies = $resp->cookies();
+ if (array_key_exists('PHPSESSID', $cookies)) // nb: make sure to use the correct session cookie name
+ {
+ $session_id = $cookies['PHPSESSID']['value'];
+
+ // do some other stuff here...
+
+ $client->setcookie('PHPSESSID', $session_id);
+ $val = $client->send(new xmlrpcmsg('getvalue', array(new xmlrpcval('foo')));
+ }
+}
+
+----
+
+Server-side sessions are handled normally like in any other
+ php application. Please see the php manual for more information about
+ sessions.
+
+NB: unlike web browsers, not all xmlrpc clients support usage of
+ http cookies. If you have troubles with sessions and control only the
+ server side of the communication, please check with the makers of the
+ xmlrpc client in use.
+
+
+[[integration]]
+
+[appendix]
+== Integration with the PHP xmlrpc extension
+
+To be documented more...
+
+In short: for the fastest execution possible, you can enable the php
+ native xmlrpc extension, and use it in conjunction with phpxmlrpc. The
+ following code snippet gives an example of such integration
+
+
+[source, php]
+----
+
+/*** client side ***/
+$c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');
+
+// tell the client to return raw xml as response value
+$c->return_type = 'xml';
+
+// let the native xmlrpc extension take care of encoding request parameters
+$r = $c->send(xmlrpc_encode_request('examples.getStateName', $_POST['stateno']));
+
+if ($r->faultCode())
+ // HTTP transport error
+ echo 'Got error '.$r->faultCode();
+else
+{
+ // HTTP request OK, but XML returned from server not parsed yet
+ $v = xmlrpc_decode($r->value());
+ // check if we got a valid xmlrpc response from server
+ if ($v === NULL)
+ echo 'Got invalid response';
+ else
+ // check if server sent a fault response
+ if (xmlrpc_is_fault($v))
+ echo 'Got xmlrpc fault '.$v['faultCode'];
+ else
+ echo'Got response: '.htmlentities($v);
+}
+
+----
+
+
+[[substitution]]
+
+[appendix]
+== Substitution of the PHP xmlrpc extension
+
+Yet another interesting situation is when you are using a ready-made
+ php application, that provides support for the XMLRPC protocol via the
+ native php xmlrpc extension, but the extension is not available on your
+ php install (e.g. because of shared hosting constraints).
+
+Since version 2.1, the PHP-XMLRPC library provides a compatibility
+ layer that aims to be 100% compliant with the xmlrpc extension API. This
+ means that any code written to run on the extension should obtain the
+ exact same results, albeit using more resources and a longer processing
+ time, using the PHP-XMLRPC library and the extension compatibility module.
+ The module is part of the EXTRAS package, available as a separate download
+ from the sourceforge.net website, since version 0.2
+
+
+[[enough]]
+
+[appendix]
+== 'Enough of xmlrpcvals!': new style library usage
+
+To be documented...
+
+In the meantime, see docs about xmlrpc_client::return_type and
+ xmlrpc_server::functions_parameters_types, as well as php_xmlrpc_encode,
+ php_xmlrpc_decode and php_xmlrpc_decode_xml
+
+
+[[debugger]]
+
+[appendix]
+== Usage of the debugger
+
+A webservice debugger is included in the library to help during
+ development and testing.
+
+The interface should be self-explicative enough to need little
+ documentation.
+
+image::debugger.gif[,,,,align="center"]
+
+The most useful feature of the debugger is without doubt the "Show
+ debug info" option. It allows to have a screen dump of the complete http
+ communication between client and server, including the http headers as
+ well as the request and response payloads, and is invaluable when
+ troubleshooting problems with charset encoding, authentication or http
+ compression.
+
+The debugger can take advantage of the JSONRPC library extension, to
+ allow debugging of JSON-RPC webservices, and of the JS-XMLRPC library
+ visual editor to allow easy mouse-driven construction of the payload for
+ remote methods. Both components have to be downloaded separately from the
+ sourceforge.net web pages and copied to the debugger directory to enable
+ the extra functionality:
+
+
+* to enable jsonrpc functionality, download the PHP-XMLRPC
+ EXTRAS package, and copy the file __jsonrpc.inc__
+ either to the same directory as the debugger or somewhere in your
+ php include path
+
+
+* to enable the visual value editing dialog, download the
+ JS-XMLRPC library, and copy somewhere in the web root files
+ __visualeditor.php__,
+ __visualeditor.css__ and the folders
+ __yui__ and __img__. Then edit the
+ debugger file __controller.php__ and set
+ appropriately the variable $editorpath.
+
+
+[[news]]
+
+[appendix]
+
+== Whats's new
+
+CAUTION: not all items the following list have (yet) been fully documented, and some might not be present in any other
+ chapter in the manual. To find a more detailed description of new functions and methods please take a look at the
+ source code of the library, which is quite thoroughly commented in phpdoc form.
+
+=== 4.0.0
+
+* new: introduction of namespaces and full OOP.
++
+All php classes have been renamed and moved to separate files.
++
+Class autoloading can now be done in accord with the PSR-4 standard.
++
+All global variables and global functions have been removed.
++
+Iterating over xmlrpc value objects is now easier thank to support for ArrayAccess and Traversable interfaces.
++
+Backward compatibility is maintained via _lib/xmlrpc.inc_, _lib/xmlrpcs.inc_ and _lib/xmlrpc_wrappers.inc_.
+ For more details, head on to doc/api_changes_v4.md
+
+* changed: the default character encoding delivered from the library to your code is now utf8.
+ It can be changed at any time setting a value to `PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding`
+
+* improved: the library now accepts requests/responses sent using other character sets than UTF-8/ISO-8859-1/ASCII.
+ This only works when the mbstring php extension is enabled.
+
+* improved: no need to call anymore `$client->setSSLVerifyHost(2)` to silence a curl warning when using https
+ with recent curl builds
+
+* improved: the xmlrpcval class now supports the interfaces `Countable` and `IteratorAggregate`
+
+* improved: a specific option allows users to decide the version of SSL to use for https calls.
+ This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
+ and the cURL extension has been compiled with GnuTLS (such as on Travis VMs)
+
+* improved: the function `wrap_php_function()` now can be used to wrap closures (it is now a method btw)
+
+* improved: all _wrap_something()_ functions now return a closure by default instead of a function name
+
+* improved: debug messages are not html-escaped any more when executing from the command line
+
+* improved: the library is now tested using Travis ( https://travis-ci.org/ ).
+ Tests are executed using all php versions from 5.3 to 7.0 nightly, plus HHVM; code-coverage information
+ is generated using php 5.6 and uploaded to both Code Coverage and Scrutinizer online services
+
+* improved: phpunit is now installed via composer, not bundled anymore
+
+* improved: when phpunit is used to generate code-coverage data, the code executed server-side is accounted for
+
+* improved: the test suite has basic checks for the debugger and demo files
+
+* improved: more tests in the test suite
+
+* fixed: the server would not reset the user-set debug messages between subsequent `service()` calls
+
+* fixed: the server would not reset previous php error handlers when an exception was thrown by user code and
+ exception_handling set to 2
+
+* fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml
+ prolog only
+
+* fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml
+ prolog only
+
+* fixed: the function `decode_xml()` would not decode an xml with character set declaration in the xml prolog
+
+* fixed: the client can now successfully call methods using ISO-8859-1 or UTF-8 characters in their name
+
+* fixed: the debugger would fail sending a request with ISO-8859-1 payload (it missed the character set declaration).
+ It would have a hard time coping with ISO-8859-1 in other fields, such as e.g. the remote method name
+
+* fixed: the debugger would generate a bad payload via the 'load method synopsis' button for signatures containing NULL
+ or undefined parameters
+
+* fixed: the debugger would generate a bad payload via the 'load method synopsis' button for methods with multiple
+ signatures
+
+* improved: the debugger is displayed using UTF-8, making it more useful to debug any kind of service
+
+* improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding;
+ previously those messages would just disappear (this is visible e.g. in the debugger)
+
+* changed: debug info handling
+ - at debug level 1, the rebuilt php objects are not dumped to screen (server-side already did that)
+ - at debug level 1, curl communication info are not dumped to screen
+ - at debug level 1, the tests echo payloads of failures; at debug level 2 all payloads
+
+* improved: makefiles have been replaced with a php_based pakefile
+
+* improved: the source for the manual is stored in asciidoc format, which can be displayed natively by GitHub
+ with nice html formatting. Also the HTML version generated by hand and bundled in tarballs is much nicer
+ to look at than previous versions
+
+* improved: all php code is now formatted according to the PSR-2 standard
+
+=== 3.0.0
+
+__Note:__ this is the last release of the library that will support PHP 5.1 and up. Future releases will target php 5.3
+ as minimum supported version.
+
+* when using curl and keepalive, reset curl handle if we did not get back an http 200 response (eg a 302)
+
+* omit port on http 'Host' header if it is 80
+
+* test suite allows interrogating https servers ignoring their certs
+
+* method `setAcceptedCompression` was failing to disable reception of compressed responses if the client supported them
+
+=== 3.0.0 beta
+
+This is the first release of the library to only support PHP 5. Some legacy code has been removed, and support for
+ features such as exceptions and dateTime objects introduced.
+
+The "beta" tag is meant to indicate the fact that the refactoring has been more widespread than in precedent releases
+ and that more changes are likely to be introduced with time - the library is still considered to be production
+ quality.
+
+* improved: removed all usage of php functions deprecated in php 5.3, usage of assign-by-ref when creating new objects
+ etc...
+
+* improved: add support for the `` tag used by the apache library, both in input and output
+
+* improved: add support for dateTime objects in both in php_xmlrpc_encode and as parameter for constructor of xmlrpcval
+
+* improved: add support for timestamps as parameter for constructor of xmlrpcval
+
+* improved: add option `dates_as_objects` to `php_xmlrpc_decode` to return dateTime objects for xmlrpc datetimes
+
+* improved: add new method `SetCurlOptions` to xmrlpc_client to allow extra flexibility in tweaking http config, such as
+ explicitly binding to an ip address
+
+* improved: add new method `SetUserAgent` to xmrlpc_client to to allow having different user-agent http headers
+
+* improved: add a new member variable in server class to allow fine-tuning of the encoding of returned values when the
+ server is in 'phpvals' mode
+
+* improved: allow servers in 'xmlrpcvals' mode to also register plain php functions by defining them in the dispatch map
+ with an added option
+
+* improved: catch exceptions thrown during execution of php functions exposed as methods by the server
+
+* fixed: bad encoding if same object is encoded twice using `php_xmlrpc_encode`
+
+=== 2.2.2
+
+__Note:__ this is the last release of the library that will support PHP 4. Future releases (if any) should target
+ php 5.0 as minimum supported version.
+
+* fixed: encoding of utf-8 characters outside of the BMP plane
+
+* fixed: character set declarations surrounded by double quotes were not recognized in http headers
+
+* fixed: be more tolerant in detection of charset in http headers
+
+* fixed: fix detection of zlib.output_compression
+
+* fixed: use `feof()` to test if socket connections are to be closed instead of the number of bytes read (rare bug when
+ communicating with some servers)
+
+* fixed: format floating point values using the correct decimal separator even when php locale is set to one that uses
+ comma
+
+* fixed: improve robustness of the debugger when parsing weird results from non-compliant servers
+
+* php warning when receiving `false` in a bool value
+
+* improved: allow the add_to_map server method to add docs for single params too
+
+* improved: added the possibility to wrap for exposure as xmlrpc methods plain php class methods, object methods and even
+ whole classes
+
+=== 2.2.1
+
+* fixed: work aroung bug in php 5.2.2 which broke support of `HTTP_RAW_POST_DATA`
+
+* fixed: is_dir parameter of `setCaCertificate()` method is reversed
+
+* fixed: a php warning in xmlrpc_client creator method
+
+* fixed: parsing of `1e+1` as valid float
+
+* fixed: allow errorlevel 3 to work when prev. error handler was a static method
+
+* fixed: usage of `client::setcookie()` for multiple cookies in non-ssl mode
+
+* improved: support for CP1252 charset is not part or the library but almost possible
+
+* improved: more info when curl is enabled and debug mode is on
+
+=== 2.2
+
+* fixed: debugger errors on php installs with `magic_quotes_gpc` on
+
+* fixed: support for https connections via proxy
+
+* fixed: `wrap_xmlrpc_method()` generated code failed to properly encode php objects
+
+* improved: slightly faster encoding of data which is internally UTF-8
+
+* improved: debugger always generates a `null` id for jsonrpc if user omits it
+
+* new: debugger can take advantage of a graphical value builder (it has to be downloaded separately, as part of jsxmlrpc
+ package. See Appendix D for more details)
+
+* new: support for the `` xmlrpc extension. see below for more details
+
+* new: server support for the `system.getCapabilities` xmlrpc extension
+
+* new: `wrap_xmlrpc_method`, `wrap_xmlrpc_method()` accepts two new options: debug and return_on_fault
+
+=== 2.1
+
+* The wrap_php_function and wrap_xmlrpc_method functions have been moved out of the base library file _xmlrpc.inc_
+ into a file of their own: _xmlrpc_wrappers.php_. You will have to include() / require() it in your scripts if
+ you have been using those functions.
+ For increased security, the automatic rebuilding of php object instances out ofreceived xmlrpc structs in
+ `wrap_xmlrpc_method()` has been disabled (but it can be optionally re-enabled).
+ Both `wrap_php_function()` and `wrap_xmlrpc_method()` functions accept many more options to fine tune their behaviour,
+ including one to return the php code to be saved and later used as standalone php script
+
+* The constructor of xmlrpcval() values has seen some internal changes, and it will not throw a php warning anymore when
+ invoked using an unknown xmlrpc type: the error will only be written to php error log. Also
+ `new xmlrpcval('true', 'boolean')` is not supported anymore
+
+* The new function `php_xmlrpc_decode_xml()` will take the xml representation of either an xmlrpc request, response or
+ single value and return the corresponding php-xmlrpc object instance
+
+* A new function `wrap_xmlrpc_server()` has been added, to wrap all (or some) of the methods exposed by a remote xmlrpc
+ server into a php class
+
+* A new file has been added: _verify_compat.php_, to help users diagnose the level of compliance of their php
+ installation with the library
+
+* Restored compatibility with php 4.0.5 (for those poor souls still stuck on it)
+
+* Method `xmlrpc_server->service()` now returns a value: either the response payload or xmlrpcresp object instance
+
+* Method `xmlrpc_server->add_to_map()` now accepts xmlrpc methods with no param definitions
+
+* Documentation for single parameters of exposed methods can be added to the dispatch map (and turned into html docs in
+ conjunction with a future release of the 'extras' package)
+
+* Full response payload is saved into xmlrpcresp object for further debugging
+
+* The debugger can now generate code that wraps a remote method into a php function (works for jsonrpc, too); it also
+ has better support for being activated via a single GET call (e.g. for integration into other tools)
+
+* Stricter parsing of incoming xmlrpc messages: two more invalid cases are now detected (double `data` element inside
+ `array` and `struct`/`array` after scalar inside `value` element)
+
+* More logging of errors in a lot of situations
+
+* Javadoc documentation of lib files (almost) complete
+
+* Many performance tweaks and code cleanups, plus the usual crop of bugs fixed (see NEWS file for complete list of bugs)
+
+* Lib internals have been modified to provide better support for grafting extra functionality on top of it. Stay tuned
+ for future releases of the EXTRAS package (or go read Appendix B)...
+
+=== 2.0 final
+
+* Added to the client class the possibility to use Digest and NTLM authentication methods (when using the CURL library)
+ for connecting to servers and NTLM for connecting to proxies
+
+* Added to the client class the possibility to specify alternate certificate files/directories for authenticating the
+ peer with when using HTTPS communication
+
+* Reviewed all examples and added a new demo file, containing a proxy to forward xmlrpc requests to other servers
+ (useful e.g. for ajax coding)
+
+* The debugger has been upgraded to reflect the new client capabilities
+
+* All known bugs have been squashed, and the lib is more tolerant than ever of commonly-found mistakes
+
+=== 2.0 Release candidate 3
+
+* Added to server class the property functions_parameters_type, that allows the server to register plain php functions
+ as xmlrpc methods (i.e. functions that do not take an xmlrpcmsg object as unique param)
+
+* let server and client objects serialize calls using a specified character set encoding for the produced xml instead of
+ US-ASCII (ISO-8859-1 and UTF-8 supported)
+
+* let `php_xmlrpc_decode` accept xmlrpcmsg objects as valid input
+
+* 'class::method' syntax is now accepted in the server dispatch map
+
+* `xmlrpc_clent::SetDebug()` accepts integer values instead of a boolean value, with debugging level 2 adding to the
+ information printed to screen the complete client request
+
+=== 2.0 Release candidate 2
+
+* Added a new property of the client object: `xmlrpc_client->return_type`, indicating whether calls to the
+ send() method will return xmlrpcresp objects whose value() is an xmlrpcval object, a php value (automatically
+ decoded) or the raw xml received from the server.
+
+* Added in the extras dir. two new library files: _jsonrpc.inc_ and _jsonrpcs.inc_ containing new classes that
+ implement support for the json-rpc protocol (alpha quality code)
+
+* Added a new client method: `setKey($key, $keypass)` to be used in HTTPS connections
+
+* Added a new file containing some benchmarks in the testsuite directory
+
+=== 2.0 Release candidate 1
+
+* Support for HTTP proxies (new method: `xmlrpc_client::setProxy()`)
+
+* Support HTTP compression of both requests and responses.
+ Clients can specify what kind of compression they accept for responses between deflate/gzip/any, and whether to
+ compress the requests.
+ Servers by default compress responses to clients that explicitly declare support for compression (new methods:
+ `xmlrpc_client::setAcceptedCompression()`, `xmlrpc_client::setRequestCompression()`).
+ Note that the ZLIB php extension needs to be enabled in PHP to support compression.
+
+* Implement HTTP 1.1 connections, but only if CURL is enabled (added an extra parameter to
+ `xmlrpc_client::xmlrpc_client` to set the desired HTTP protocol at creation time and a new supported value for
+ the last parameter of `xmlrpc_client::send`, which now can be safely omitted if it has been specified at
+ creation time).
++
+With PHP versions greater than 4.3.8 keep-alives are enabled by default for HTTP 1.1 connections. This should yield
+ faster execution times when making multiple calls in sequence to the same xml-rpc server from a single client.
+
+* Introduce support for cookies.
+ Cookies to be sent to the server with a request can be set using `xmlrpc_client::setCookie()`, while cookies
+ received from the server are found in ++xmlrpcresp::cookies()++. It is left to the user to check for validity of
+ received cookies and decide whether they apply to successive calls or not.
+
+* Better support for detecting different character set encodings of xml-rpc requests and responses: both client and
+ server objects will correctly detect the charset encoding of received xml, and use an appropriate xml parser.
++
+Supported encodings are US-ASCII, UTF-8 and ISO-8859-1.
+
+* Added one new xmlrpcmsg constructor syntax, allowing usage of a single string with the complete URL of the target
+ server
+
+* Convert xml-rpc boolean values into native php values instead of 0 and 1
+
+* Force the `php_xmlrpc_encode` function to properly encode numerically indexed php arrays into xml-rpc arrays
+ (numerically indexed php arrays always start with a key of 0 and increment keys by values of 1)
+
+* Prevent the `php_xmlrpc_encode` function from further re-encoding any objects of class ++xmlrpcval++ that
+ are passed to it. This allows to call the function with arguments consisting of mixed php values / xmlrpcval objects
+
+* Allow a server to NOT respond to system.* method calls (setting the `$server->allow_system_funcs` property).
+
+* Implement a new xmlrpcval method to determine if a value of type struct has a member of a given name without having to
+ loop trough all members: `xmlrpcval::structMemExists()`
+
+* Expand methods `xmlrpcval::addArray`, `addScalar` and `addStruct` allowing extra php values to be added to
+ xmlrpcval objects already formed.
+
+* Let the `xmlrpc_client::send` method accept an XML string for sending instead of an xmlrpcmsg object, to
+ facilitate debugging and integration with the php native xmlrpc extension
+
+* Extend the `php_xmlrpc_encode` and `php_xmlrpc_decode` functions to allow serialization and rebuilding of
+ PHP objects. To successfully rebuild a serialized object, the object class must be defined in the deserializing end
+ of the transfer. Note that object members of type resource will be deserialized as NULL values.
++
+Note that his has been implemented adding a "php_class" attribute to xml representation of xmlrpcval of STRUCT type,
+ which, strictly speaking, breaks the xml-rpc spec. Other xmlrpc implementations are supposed to ignore such an
+ attribute (unless they implement a brain-dead custom xml parser...), so it should be safe enabling it in
+ heterogeneous environments. The activation of this feature is done by usage of an option passed as second parameter
+ to both `php_xmlrpc_encode` and `php_xmlrpc_decode`.
+
+* Extend the `php_xmlrpc_encode` function to allow automatic serialization of iso8601-conforming php strings as
+ datetime.iso8601 xmlrpcvals, by usage of an optional parameter
+
+* Added an automatic stub code generator for converting xmlrpc methods to php functions and vice-versa.
++
+This is done via two new functions: `wrap_php_function` and `wrap_xmlrpc_method`, and has many caveats,
+ with php being a typeless language and all...
+
+* Allow object methods to be used in server dispatch map
+
+* Added a complete debugger solution, in the __debugger__ folder
+
+* Added configurable server-side debug messages, controlled by the new method `xmlrpc_server::SetDebug()`.
+ At level 0, no debug messages are sent to the client; level 1 is the same as the old behaviour; at level 2 a lot
+ more info is echoed back to the client, regarding the received call; at level 3 all warnings raised during server
+ processing are trapped (this prevents breaking the xml to be echoed back to the client) and added to the debug info
+ sent back to the client
+
+* New XML parsing code, yields smaller memory footprint and faster execution times, not to mention complete elimination
+ of the dreaded __eval()__ construct, so prone to code injection exploits
+
+* Rewritten most of the error messages, making text more explicative
+
+++++++++++++++++++++++++++++++++++++++
+
+++++++++++++++++++++++++++++++++++++++
diff --git a/php/phpxmlrpc/extras/rsakey.pem b/php/phpxmlrpc/extras/rsakey.pem
new file mode 100644
index 0000000..6c51248
--- /dev/null
+++ b/php/phpxmlrpc/extras/rsakey.pem
@@ -0,0 +1,9 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOgIBAAJBAM12w6/J20HMj0V9VC24xPFQG9RKSDt8vmviM+tnc1BgCrzPyF1v
+3/rWGoWDjkJrE9WFOeqIjJHeEWWT4uKq2ZkCAwEAAQJAZZYJ7Nld+et9DvuHak/H
+uBRGnjDYA+mKcObXitWMUzk2ZodL8UoCP1J9kKqV8Zp/l2cBZkLo0aWTN94sWkHy
+rQIhAOhxWxRXSZ4kArIQqZnDG9JgtOAeaaFso/zpxIHpN6OrAiEA4klzl+rUc32/
+7SDcJYa9j5vehp1jCTnkN+n0rujTM8sCIAGwMRUovSQk5tAcRt8TB7SzdxzZm7LM
+czR3DjJTW1AZAiEAlYN+svPgJ+cAdwdtLgZXHZoZb8xx8Vik6CTXHPKNCf0CIBQL
+zF4Qp8/C+gjsXtEZJvhxY7i1luHn6iNwNnE932r3
+-----END RSA PRIVATE KEY-----
diff --git a/php/phpxmlrpc/extras/test.pl b/php/phpxmlrpc/extras/test.pl
new file mode 100644
index 0000000..6b3cec0
--- /dev/null
+++ b/php/phpxmlrpc/extras/test.pl
@@ -0,0 +1,52 @@
+#!/usr/local/bin/perl
+
+use Frontier::Client;
+
+my $serverURL='http://phpxmlrpc.sourceforge.net/server.php';
+
+# try the simplest example
+
+my $client = Frontier::Client->new( 'url' => $serverURL,
+ 'debug' => 0, 'encoding' => 'iso-8859-1' );
+my $resp = $client->call("examples.getStateName", 32);
+
+print "Got '${resp}'\n";
+
+# now send a mail to nobody in particular
+
+$resp = $client->call("mail.send", ("edd", "Test",
+ "Bonjour. Je m'appelle Gérard. Mañana. ", "freddy", "", "",
+ 'text/plain; charset="iso-8859-1"'));
+
+if ($resp->value()) {
+ print "Mail sent OK.\n";
+} else {
+ print "Error sending mail.\n";
+}
+
+# test echoing of characters works fine
+
+$resp = $client->call("examples.echo", 'Three "blind" mice - ' .
+ "See 'how' they run");
+print $resp . "\n";
+
+# test name and age example. this exercises structs and arrays
+
+$resp = $client->call("examples.sortByAge",
+ [ { 'name' => 'Dave', 'age' => 35},
+ { 'name' => 'Edd', 'age' => 45 },
+ { 'name' => 'Fred', 'age' => 23 },
+ { 'name' => 'Barney', 'age' => 36 } ] );
+
+my $e;
+foreach $e (@$resp) {
+ print $$e{'name'} . ", " . $$e{'age'} . "\n";
+}
+
+# test base64
+
+$resp = $client->call("examples.decode64",
+ $client->base64("TWFyeSBoYWQgYSBsaXR0bGUgbGFtYiBTaGUgd" .
+ "GllZCBpdCB0byBhIHB5bG9u"));
+
+print $resp . "\n";
diff --git a/php/phpxmlrpc/extras/test.py b/php/phpxmlrpc/extras/test.py
new file mode 100644
index 0000000..adc0aea
--- /dev/null
+++ b/php/phpxmlrpc/extras/test.py
@@ -0,0 +1,37 @@
+#!/usr/local/bin/python
+
+from xmlrpclib import *
+import sys
+
+server = Server("http://phpxmlrpc.sourceforge.net/server.php")
+
+try:
+ print "Got '" + server.examples.getStateName(32) + "'"
+
+ r = server.mail.send("edd", "Test",
+ "Bonjour. Je m'appelle Gérard. Mañana. ", "freddy", "", "",
+ 'text/plain; charset="iso-8859-1"')
+ if r:
+ print "Mail sent OK"
+ else:
+ print "Error sending mail"
+
+
+ r = server.examples.echo('Three "blind" mice - ' + "See 'how' they run")
+ print r
+
+ # name/age example. this exercises structs and arrays
+
+ a = [ {'name': 'Dave', 'age': 35}, {'name': 'Edd', 'age': 45 },
+ {'name': 'Fred', 'age': 23}, {'name': 'Barney', 'age': 36 }]
+ r = server.examples.sortByAge(a)
+ print r
+
+ # test base 64
+ b = Binary("Mary had a little lamb She tied it to a pylon")
+ b.encode(sys.stdout)
+ r = server.examples.decode64(b)
+ print r
+
+except Error, v:
+ print "XML-RPC Error:",v
diff --git a/php/phpxmlrpc/extras/workspace.testPhpServer.fttb b/php/phpxmlrpc/extras/workspace.testPhpServer.fttb
new file mode 100644
index 0000000..8d50758
--- /dev/null
+++ b/php/phpxmlrpc/extras/workspace.testPhpServer.fttb
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/php/phpxmlrpc/lib/xmlrpc.inc b/php/phpxmlrpc/lib/xmlrpc.inc
new file mode 100644
index 0000000..28b47d3
--- /dev/null
+++ b/php/phpxmlrpc/lib/xmlrpc.inc
@@ -0,0 +1,217 @@
+
+
+// Copyright (c) 1999,2000,2002 Edd Dumbill.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// * Neither the name of the "XML-RPC for PHP" nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/******************************************************************************
+ *
+ * *** DEPRECATED ***
+ *
+ * This file is only used to insure backwards compatibility
+ * with the API of the library <= rev. 3
+ *
+ * If it is included, the library will work without any further autoloading
+ *****************************************************************************/
+
+include_once(__DIR__.'/../src/PhpXmlRpc.php');
+include_once(__DIR__.'/../src/Value.php');
+include_once(__DIR__.'/../src/Request.php');
+include_once(__DIR__.'/../src/Response.php');
+include_once(__DIR__.'/../src/Client.php');
+include_once(__DIR__.'/../src/Encoder.php');
+include_once(__DIR__.'/../src/Helper/Charset.php');
+include_once(__DIR__.'/../src/Helper/Date.php');
+include_once(__DIR__.'/../src/Helper/Http.php');
+include_once(__DIR__.'/../src/Helper/Logger.php');
+include_once(__DIR__.'/../src/Helper/XMLParser.php');
+
+
+/* Expose the global variables which used to be defined */
+PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1'; // old default
+PhpXmlRpc\PhpXmlRpc::exportGlobals();
+
+/* some stuff deprecated enough that we do not want to put it in the new lib version */
+
+/// @deprecated
+$GLOBALS['xmlEntities'] = array(
+ 'amp' => '&',
+ 'quot' => '"',
+ 'lt' => '<',
+ 'gt' => '>',
+ 'apos' => "'"
+);
+
+// formulate backslashes for escaping regexp
+// Not in use anymore since 2.0. Shall we remove it?
+/// @deprecated
+$GLOBALS['xmlrpc_backslash'] = chr(92).chr(92);
+
+/* Expose with the old names the classes which have been namespaced */
+
+class xmlrpcval extends PhpXmlRpc\Value
+{
+ /**
+ * @deprecated
+ * @param xmlrpcval $o
+ * @return string
+ */
+ public function serializeval($o)
+ {
+ // 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')))
+ //{
+ $ar = $o->me;
+ reset($ar);
+ list($typ, $val) = each($ar);
+
+ return '' . $this->serializedata($typ, $val) . "\n";
+ //}
+ }
+
+ /**
+ * @deprecated this code looks like it is very fragile and has not been fixed
+ * for a long long time. Shall we remove it for 2.0?
+ */
+ public function getval()
+ {
+ // UNSTABLE
+ reset($this->me);
+ list($a, $b) = each($this->me);
+ // contributed by I Sofer, 2001-03-24
+ // add support for nested arrays to scalarval
+ // i've created a new method here, so as to
+ // preserve back compatibility
+
+ if (is_array($b)) {
+ @reset($b);
+ while (list($id, $cont) = @each($b)) {
+ $b[$id] = $cont->scalarval();
+ }
+ }
+
+ // add support for structures directly encoding php objects
+ if (is_object($b)) {
+ $t = get_object_vars($b);
+ @reset($t);
+ while (list($id, $cont) = @each($t)) {
+ $t[$id] = $cont->scalarval();
+ }
+ @reset($t);
+ while (list($id, $cont) = @each($t)) {
+ @$b->$id = $cont;
+ }
+ }
+ // end contrib
+ return $b;
+ }
+
+ /// reset functionality added by parent class: same as it would happen if no interface was declared
+ public function count()
+ {
+ return 1;
+ }
+
+ /// reset functionality added by parent class: same as it would happen if no interface was declared
+ public function getIterator() {
+ return new ArrayIterator($this);
+ }
+}
+
+class xmlrpcmsg extends PhpXmlRpc\Request
+{
+}
+
+class xmlrpcresp extends PhpXmlRpc\Response
+{
+}
+
+class xmlrpc_client extends PhpXmlRpc\Client
+{
+}
+
+/* Expose as global functions the ones which are now class methods */
+
+/// Wrong speling, but we are adamant on backwards compatibility!
+function xmlrpc_encode_entitites($data, $srcEncoding='', $destEncoding='')
+{
+ return PhpXmlRpc\Helper\Charset::instance()->encodeEntitites($data, $srcEncoding, $destEncoding);
+}
+
+function iso8601_encode($timeT, $utc=0)
+{
+ return PhpXmlRpc\Helper\Date::iso8601Encode($timeT, $utc);
+}
+
+function iso8601_decode($iDate, $utc=0)
+{
+ return PhpXmlRpc\Helper\Date::iso8601Decode($iDate, $utc);
+}
+
+function decode_chunked($buffer)
+{
+ return PhpXmlRpc\Helper\Http::decodeChunked($buffer);
+}
+
+function php_xmlrpc_decode($xmlrpcVal, $options=array())
+{
+ $encoder = new PhpXmlRpc\Encoder();
+ return $encoder->decode($xmlrpcVal, $options);
+}
+
+function php_xmlrpc_encode($phpVal, $options=array())
+{
+ $encoder = new PhpXmlRpc\Encoder();
+ return $encoder->encode($phpVal, $options);
+}
+
+function php_xmlrpc_decode_xml($xmlVal, $options=array())
+{
+ $encoder = new PhpXmlRpc\Encoder();
+ return $encoder->decodeXml($xmlVal, $options);
+}
+
+function guess_encoding($httpHeader='', $xmlChunk='', $encodingPrefs=null)
+{
+ return PhpXmlRpc\Helper\XMLParser::guessEncoding($httpHeader, $xmlChunk, $encodingPrefs);
+}
+
+function has_encoding($xmlChunk)
+{
+ return PhpXmlRpc\Helper\XMLParser::hasEncoding($xmlChunk);
+}
+
+function is_valid_charset($encoding, $validList)
+{
+ return PhpXmlRpc\Helper\Charset::instance()->isValidCharset($encoding, $validList);
+}
diff --git a/php/phpxmlrpc/lib/xmlrpc_wrappers.inc b/php/phpxmlrpc/lib/xmlrpc_wrappers.inc
new file mode 100644
index 0000000..cec3374
--- /dev/null
+++ b/php/phpxmlrpc/lib/xmlrpc_wrappers.inc
@@ -0,0 +1,243 @@
+php2XmlrpcType($phpType);
+}
+
+/**
+ * @see PhpXmlRpc\Wrapper::xmlrpc_2_php_type
+ * @param string $xmlrpcType
+ * @return string
+ */
+function xmlrpc_2_php_type($xmlrpcType)
+{
+ $wrapper = new PhpXmlRpc\Wrapper();
+ return $wrapper->xmlrpc2PhpType($xmlrpcType);
+}
+
+/**
+ * @see PhpXmlRpc\Wrapper::wrap_php_function
+ * @param callable $funcName
+ * @param string $newFuncName
+ * @param array $extraOptions
+ * @return array|false
+ */
+function wrap_php_function($funcName, $newFuncName='', $extraOptions=array())
+{
+ $wrapper = new PhpXmlRpc\Wrapper();
+ if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) {
+ // backwards compat: return string instead of callable
+ $extraOptions['return_source'] = true;
+ $wrapped = $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions);
+ eval($wrapped['source']);
+ } else {
+ $wrapped = $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions);
+ }
+ return $wrapped;
+}
+
+/**
+ * NB: this function returns an array in a format which is unsuitable for direct use in the server dispatch map, unlike
+ * PhpXmlRpc\Wrapper::wrapPhpClass. This behaviour might seem like a bug, but has been kept for backwards compatibility.
+ *
+ * @see PhpXmlRpc\Wrapper::wrap_php_class
+ * @param string|object $className
+ * @param array $extraOptions
+ * @return array|false
+ */
+function wrap_php_class($className, $extraOptions=array())
+{
+ $wrapper = new PhpXmlRpc\Wrapper();
+ $fix = false;
+ if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) {
+ // backwards compat: return string instead of callable
+ $extraOptions['return_source'] = true;
+ $fix = true;
+ }
+ $wrapped = $wrapper->wrapPhpClass($className, $extraOptions);
+ foreach($wrapped as $name => $value) {
+ if ($fix) {
+ eval($value['source']);
+ }
+ $wrapped[$name] = $value['function'];
+ }
+ return $wrapped;
+}
+
+/**
+ * @see PhpXmlRpc\Wrapper::wrapXmlrpcMethod
+ * @param xmlrpc_client $client
+ * @param string $methodName
+ * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option in $extraOptions
+ * @param int $timeout deprecated, use an option in $extraOptions
+ * @param string $protocol deprecated, use an option in $extraOptions
+ * @param string $newFuncName deprecated, use an option in $extraOptions
+ * @return array|callable|false
+ */
+function wrap_xmlrpc_method($client, $methodName, $extraOptions=0, $timeout=0, $protocol='', $newFuncName='')
+{
+ if (!is_array($extraOptions))
+ {
+ $sigNum = $extraOptions;
+ $extraOptions = array(
+ 'signum' => $sigNum,
+ 'timeout' => $timeout,
+ 'protocol' => $protocol,
+ 'new_function_name' => $newFuncName
+ );
+ }
+
+ $wrapper = new PhpXmlRpc\Wrapper();
+
+ if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) {
+ // backwards compat: return string instead of callable
+ $extraOptions['return_source'] = true;
+ $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions);
+ eval($wrapped['source']);
+ $wrapped = $wrapped['function'];
+ } else {
+ $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions);
+ }
+ return $wrapped;
+}
+
+/**
+ * @see PhpXmlRpc\Wrapper::wrap_xmlrpc_server
+ * @param xmlrpc_client $client
+ * @param array $extraOptions
+ * @return mixed
+ */
+function wrap_xmlrpc_server($client, $extraOptions=array())
+{
+ $wrapper = new PhpXmlRpc\Wrapper();
+ return $wrapper->wrapXmlrpcServer($client, $extraOptions);
+}
+
+/**
+ * Given the necessary info, build php code that creates a new function to invoke a remote xmlrpc method.
+ * Take care that no full checking of input parameters is done to ensure that valid php code is emitted.
+ * Only kept for backwards compatibility
+ * Note: real spaghetti code follows...
+ *
+ * @deprecated
+ */
+function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
+ $mSig, $mDesc = '', $timeout = 0, $protocol = '', $clientCopyMode = 0, $prefix = 'xmlrpc',
+ $decodePhpObjects = false, $encodePhpObjects = false, $decodeFault = false,
+ $faultResponse = '', $namespace = '\\PhpXmlRpc\\')
+{
+ $code = "function $xmlrpcFuncName (";
+ if ($clientCopyMode < 2) {
+ // client copy mode 0 or 1 == partial / full client copy in emitted code
+ $innerCode = build_client_wrapper_code($client, $clientCopyMode, $prefix, $namespace);
+ $innerCode .= "\$client->setDebug(\$debug);\n";
+ $this_ = '';
+ } else {
+ // client copy mode 2 == no client copy in emitted code
+ $innerCode = '';
+ $this_ = 'this->';
+ }
+ $innerCode .= "\$req = new {$namespace}Request('$methodName');\n";
+
+ if ($mDesc != '') {
+ // take care that PHP comment is not terminated unwillingly by method description
+ $mDesc = "/**\n* " . str_replace('*/', '* /', $mDesc) . "\n";
+ } else {
+ $mDesc = "/**\nFunction $xmlrpcFuncName\n";
+ }
+
+ // param parsing
+ $innerCode .= "\$encoder = new {$namespace}Encoder();\n";
+ $plist = array();
+ $pCount = count($mSig);
+ for ($i = 1; $i < $pCount; $i++) {
+ $plist[] = "\$p$i";
+ $pType = $mSig[$i];
+ if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
+ $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
+ ) {
+ // only build directly xmlrpc values when type is known and scalar
+ $innerCode .= "\$p$i = new {$namespace}Value(\$p$i, '$pType');\n";
+ } else {
+ if ($encodePhpObjects) {
+ $innerCode .= "\$p$i = \$encoder->encode(\$p$i, array('encode_php_objs'));\n";
+ } else {
+ $innerCode .= "\$p$i = \$encoder->encode(\$p$i);\n";
+ }
+ }
+ $innerCode .= "\$req->addparam(\$p$i);\n";
+ $mDesc .= '* @param ' . xmlrpc_2_php_type($pType) . " \$p$i\n";
+ }
+ if ($clientCopyMode < 2) {
+ $plist[] = '$debug=0';
+ $mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
+ }
+ $plist = implode(', ', $plist);
+ $mDesc .= '* @return ' . xmlrpc_2_php_type($mSig[0]) . " (or an {$namespace}Response obj instance if call fails)\n*/\n";
+
+ $innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n";
+ if ($decodeFault) {
+ if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) {
+ $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')";
+ } else {
+ $respCode = var_export($faultResponse, true);
+ }
+ } else {
+ $respCode = '$res';
+ }
+ if ($decodePhpObjects) {
+ $innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value(), array('decode_php_objs'));";
+ } else {
+ $innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());";
+ }
+
+ $code = $code . $plist . ") {\n" . $innerCode . "\n}\n";
+
+ return array('source' => $code, 'docstring' => $mDesc);
+}
+
+/**
+ * @deprecated
+ */
+function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc')
+{
+ $code = "\$client = new {$prefix}_client('".str_replace("'", "\'", $client->path).
+ "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
+
+ // copy all client fields to the client that will be generated runtime
+ // (this provides for future expansion or subclassing of client obj)
+ if ($verbatim_client_copy)
+ {
+ foreach($client as $fld => $val)
+ {
+ if($fld != 'debug' && $fld != 'return_type')
+ {
+ $val = var_export($val, true);
+ $code .= "\$client->$fld = $val;\n";
+ }
+ }
+ }
+ // only make sure that client always returns the correct data type
+ $code .= "\$client->return_type = '{$prefix}vals';\n";
+ //$code .= "\$client->setDebug(\$debug);\n";
+ return $code;
+}
diff --git a/php/phpxmlrpc/lib/xmlrpcs.inc b/php/phpxmlrpc/lib/xmlrpcs.inc
new file mode 100644
index 0000000..71cde1f
--- /dev/null
+++ b/php/phpxmlrpc/lib/xmlrpcs.inc
@@ -0,0 +1,121 @@
+
+
+// Copyright (c) 1999,2000,2002 Edd Dumbill.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// * Neither the name of the "XML-RPC for PHP" nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/******************************************************************************
+ *
+ * *** DEPRECATED ***
+ *
+ * This file is only used to insure backwards compatibility
+ * with the API of the library <= rev. 3
+ *****************************************************************************/
+
+include_once(__DIR__.'/../src/Server.php');
+
+class xmlrpc_server extends PhpXmlRpc\Server
+{
+ /**
+ * A debugging routine: just echoes back the input packet as a string value
+ * @deprecated
+ */
+ public function echoInput()
+ {
+ $r = new Response(new PhpXmlRpc\Value("'Aha said I: '" . file_get_contents('php://input'), 'string'));
+ print $r->serialize();
+ }
+}
+
+/* Expose as global functions the ones which are now class methods */
+
+/**
+ * @see PhpXmlRpc\Server::xmlrpc_debugmsg
+ * @param string $m
+ */
+function xmlrpc_debugmsg($m)
+{
+ PhpXmlRpc\Server::xmlrpc_debugmsg($m);
+}
+
+function _xmlrpcs_getCapabilities($server, $m=null)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_getCapabilities($server, $m);
+}
+
+$_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray']));
+$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
+$_xmlrpcs_listMethods_sdoc=array(array('list of method names'));
+function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing
+{
+ return PhpXmlRpc\Server::_xmlrpcs_listMethods($server, $m);
+}
+
+$_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString']));
+$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
+$_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described'));
+function _xmlrpcs_methodSignature($server, $m)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_methodSignature($server, $m);
+}
+
+$_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString']));
+$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
+$_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described'));
+function _xmlrpcs_methodHelp($server, $m)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_methodHelp($server, $m);
+}
+
+function _xmlrpcs_multicall_error($err)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_multicall_error($err);
+}
+
+function _xmlrpcs_multicall_do_call($server, $call)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_multicall_do_call($server, $call);
+}
+
+function _xmlrpcs_multicall_do_call_phpvals($server, $call)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_multicall_do_call_phpvals($server, $call);
+}
+
+$_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray']));
+$_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details';
+$_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"'));
+function _xmlrpcs_multicall($server, $m)
+{
+ return PhpXmlRpc\Server::_xmlrpcs_multicall($server, $m);
+}
diff --git a/php/phpxmlrpc/license.txt b/php/phpxmlrpc/license.txt
new file mode 100644
index 0000000..37313ac
--- /dev/null
+++ b/php/phpxmlrpc/license.txt
@@ -0,0 +1,29 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 1999,2000,2001 Edd Dumbill, Useful Information Company
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the "XML-RPC for PHP" nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/php/phpxmlrpc/pakefile.php b/php/phpxmlrpc/pakefile.php
new file mode 100644
index 0000000..4bca828
--- /dev/null
+++ b/php/phpxmlrpc/pakefile.php
@@ -0,0 +1,400 @@
+ 'asciidoctor',
+ 'fop' => 'fop',
+ 'php' => 'php',
+ 'zip' => 'zip',
+ );
+ protected static $options = array(
+ 'repo' => 'https://github.com/gggeek/phpxmlrpc',
+ 'branch' => 'master'
+ );
+
+ public static function libVersion()
+ {
+ if (self::$libVersion == null)
+ throw new \Exception('Missing library version argument');
+ return self::$libVersion;
+ }
+
+ public static function buildDir()
+ {
+ return self::$buildDir;
+ }
+
+ public static function workspaceDir()
+ {
+ return self::buildDir().'/workspace';
+ }
+
+ /// most likely things will break if this one is moved outside of BuildDir
+ public static function distDir()
+ {
+ return self::buildDir().'/xmlrpc-'.self::libVersion();
+ }
+
+ /// these will be generated in BuildDir
+ public static function distFiles()
+ {
+ return array(
+ 'xmlrpc-'.self::libVersion().'.tar.gz',
+ 'xmlrpc-'.self::libVersion().'.zip',
+ );
+ }
+
+ public static function getOpts($args=array(), $cliOpts=array())
+ {
+ if (count($args) > 0)
+ // throw new \Exception('Missing library version argument');
+ self::$libVersion = $args[0];
+
+ foreach (self::$tools as $name => $binary) {
+ if (isset($cliOpts[$name])) {
+ self::$tools[$name] = $cliOpts[$name];
+ }
+ }
+
+ foreach (self::$options as $name => $value) {
+ if (isset($cliOpts[$name])) {
+ self::$options[$name] = $cliOpts[$name];
+ }
+ }
+
+ //pake_echo('---'.self::$libVersion.'---');
+ }
+
+ /**
+ * @param string $name
+ * @return string
+ */
+ public static function tool($name)
+ {
+ return self::$tools[$name];
+ }
+
+ /**
+ * @param string $name
+ * @return string
+ */
+ public static function option($name)
+ {
+ return self::$options[$name];
+ }
+
+ /**
+ * @param string $inFile
+ * @param string $xssFile
+ * @param string $outFileOrDir
+ * @throws \Exception
+ */
+ public static function applyXslt($inFile, $xssFile, $outFileOrDir)
+ {
+
+ if (!file_exists($inFile)) {
+ throw new \Exception("File $inFile cannot be found");
+ }
+ if (!file_exists($xssFile)) {
+ throw new \Exception("File $xssFile cannot be found");
+ }
+
+ // Load the XML source
+ $xml = new \DOMDocument();
+ $xml->load($inFile);
+ $xsl = new \DOMDocument();
+ $xsl->load($xssFile);
+
+ // Configure the transformer
+ $processor = new \XSLTProcessor();
+ if (version_compare(PHP_VERSION, '5.4', "<")) {
+ if (defined('XSL_SECPREF_WRITE_FILE')) {
+ ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
+ }
+ } else {
+ // the php online docs only mention setSecurityPrefs, but somehow some installs have setSecurityPreferences...
+ if (method_exists('XSLTProcessor', 'setSecurityPrefs')) {
+ $processor->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
+ } else {
+ $processor->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
+ }
+ }
+ $processor->importStyleSheet($xsl); // attach the xsl rules
+
+ if (is_dir($outFileOrDir)) {
+ if (!$processor->setParameter('', 'base.dir', realpath($outFileOrDir))) {
+ echo "setting param base.dir KO\n";
+ }
+ }
+
+ $out = $processor->transformToXML($xml);
+
+ if (!is_dir($outFileOrDir)) {
+ file_put_contents($outFileOrDir, $out);
+ }
+ }
+
+ public static function highlightPhpInHtml($content)
+ {
+ $startTag = '
';
+ $endTag = '
';
+
+ //$content = file_get_contents($inFile);
+ $last = 0;
+ $out = '';
+ while (($start = strpos($content, $startTag, $last)) !== false) {
+ $end = strpos($content, $endTag, $start);
+ $code = substr($content, $start + strlen($startTag), $end - $start - strlen($startTag));
+ if ($code[strlen($code) - 1] == "\n") {
+ $code = substr($code, 0, -1);
+ }
+
+ $code = str_replace(array('>', '<'), array('>', '<'), $code);
+ $code = highlight_string('<?php ', '', $code);
+
+ $out = $out . substr($content, $last, $start + strlen($startTag) - $last) . $code . $endTag;
+ $last = $end + strlen($endTag);
+ }
+ $out .= substr($content, $last, strlen($content));
+
+ return $out;
+ }
+}
+
+}
+
+namespace {
+
+use PhpXmlRpc\Builder;
+
+function run_default($task=null, $args=array(), $cliOpts=array())
+{
+ echo "Syntax: pake {\$pake-options} \$task \$lib-version [\$git-tag] {\$task-options}\n";
+ echo "\n";
+ echo " Run 'pake help' to list all pake options\n";
+ echo " Run 'pake -T' to list available tasks\n";
+ echo " Run 'pake -P' to list all available tasks (including hidden ones) and their dependencies\n";
+ echo "\n";
+ echo " Task options:\n";
+ echo " --repo=REPO URL of the source repository to clone. Defaults to the github repo.\n";
+ echo " --branch=BRANCH The git branch to build from.\n";
+ echo " --asciidoctor=ASCIIDOCTOR Location of the asciidoctor command-line tool\n";
+ echo " --fop=FOP Location of the apache fop command-line tool\n";
+ echo " --php=PHP Location of the php command-line interpreter\n";
+ echo " --zip=ZIP Location of the zip tool\n";
+}
+
+function run_getopts($task=null, $args=array(), $cliOpts=array())
+{
+ Builder::getOpts($args, $cliOpts);
+}
+
+/**
+ * Downloads source code in the build workspace directory, optionally checking out the given branch/tag
+ */
+function run_init($task=null, $args=array(), $cliOpts=array())
+{
+ // download the current version into the workspace
+ $targetDir = Builder::workspaceDir();
+
+ // check if workspace exists and is not already set to the correct repo
+ if (is_dir($targetDir) && pakeGit::isRepository($targetDir)) {
+ $repo = new pakeGit($targetDir);
+ $remotes = $repo->remotes();
+ if (trim($remotes['origin']['fetch']) != Builder::option('repo')) {
+ throw new Exception("Directory '$targetDir' exists and is not linked to correct git repo");
+ }
+
+ /// @todo should we not just fetch instead?
+ $repo->pull();
+ } else {
+ pake_mkdirs(dirname($targetDir));
+ $repo = pakeGit::clone_repository(Builder::option('repo'), Builder::workspaceDir());
+ }
+
+ $repo->checkout(Builder::option('branch'));
+}
+
+/**
+ * Runs all the build steps.
+ *
+ * (does nothing by itself, as all the steps are managed via task dependencies)
+ */
+function run_build($task=null, $args=array(), $cliOpts=array())
+{
+}
+
+function run_clean_doc()
+{
+ pake_remove_dir(Builder::workspaceDir().'/doc/api');
+ $finder = pakeFinder::type('file')->name('*.html');
+ pake_remove($finder, Builder::workspaceDir().'/doc/manual');
+ $finder = pakeFinder::type('file')->name('*.xml');
+ pake_remove($finder, Builder::workspaceDir().'/doc/manual');
+}
+
+/**
+ * Generates documentation in all formats
+ */
+function run_doc($task=null, $args=array(), $cliOpts=array())
+{
+ $docDir = Builder::workspaceDir().'/doc';
+
+ // API docs
+
+ // from phpdoc comments using phpdocumentor
+ //$cmd = Builder::tool('php');
+ //pake_sh("$cmd vendor/phpdocumentor/phpdocumentor/bin/phpdoc run -d ".Builder::workspaceDir().'/src'." -t ".Builder::workspaceDir().'/doc/api --title PHP-XMLRPC');
+
+ // from phpdoc comments using Sami
+ $samiConfig = <<files()
+ ->exclude('debugger')
+ ->exclude('demo')
+ ->exclude('doc')
+ ->exclude('tests')
+ ->in('./build/workspace');
+ return new Sami\Sami(\$iterator, array(
+ 'title' => 'PHP-XMLRPC',
+ 'build_dir' => 'build/workspace/doc/api',
+ 'cache_dir' => 'build/cache',
+ ));
+EOT;
+ file_put_contents('build/sami_config.php', $samiConfig);
+ $cmd = Builder::tool('php');
+ pake_sh("$cmd vendor/sami/sami/sami.php update -vvv build/sami_config.php");
+
+ // User Manual
+
+ // html (single file) from asciidoc
+ $cmd = Builder::tool('asciidoctor');
+ pake_sh("$cmd -d book $docDir/manual/phpxmlrpc_manual.adoc");
+
+ // then docbook from asciidoc
+ /// @todo create phpxmlrpc_manual.xml with the good version number
+ /// @todo create phpxmlrpc_manual.xml with the date set to the one of last commit (or today?)
+ pake_sh("$cmd -d book -b docbook $docDir/manual/phpxmlrpc_manual.adoc");
+
+ # Other tools for docbook...
+ #
+ # jade cmd yet to be rebuilt, starting from xml file and putting output in ./out dir, e.g.
+ # jade -t xml -d custom.dsl xmlrpc_php.xml
+ #
+ # convertdoc command for xmlmind xxe editor
+ # convertdoc docb.toHTML xmlrpc_php.xml -u out
+ #
+ # saxon + xerces xml parser + saxon extensions + xslthl: adds a little syntax highligting
+ # (bold and italics only, no color) for php source examples...
+ # java \
+ # -classpath c:\programmi\saxon\saxon.jar\;c:\programmi\saxon\xslthl.jar\;c:\programmi\xerces\xercesImpl.jar\;C:\htdocs\xmlrpc_cvs\docbook-xsl\extensions\saxon65.jar \
+ # -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
+ # -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
+ # -Dxslthl.config=file:///c:/htdocs/xmlrpc_cvs/docbook-xsl/highlighting/xslthl-config.xml \
+ # com.icl.saxon.StyleSheet -o xmlrpc_php.fo.xml xmlrpc_php.xml custom.fo.xsl use.extensions=1
+
+ // HTML (multiple files) from docbook - discontinued, as we use the nicer-looking html gotten from asciidoc
+ /*Builder::applyXslt($docDir.'/manual/phpxmlrpc_manual.xml', $docDir.'/build/custom.xsl', $docDir.'/manual');
+ // post process html files to highlight php code samples
+ foreach(pakeFinder::type('file')->name('*.html')->in($docDir.'/manual') as $file)
+ {
+ file_put_contents($file, Builder::highlightPhpInHtml(file_get_contents($file)));
+ }*/
+
+ // PDF file from docbook
+
+ // convert to fo and then to pdf using apache fop
+ Builder::applyXslt($docDir.'/manual/phpxmlrpc_manual.xml', $docDir.'/build/custom.fo.xsl', $docDir.'/manual/phpxmlrpc_manual.fo.xml');
+ $cmd = Builder::tool('fop');
+ pake_sh("$cmd $docDir/manual/phpxmlrpc_manual.fo.xml $docDir/manual/phpxmlrpc_manual.pdf");
+
+ // cleanup
+ unlink($docDir.'/manual/phpxmlrpc_manual.xml');
+ unlink($docDir.'/manual/phpxmlrpc_manual.fo.xml');
+}
+
+function run_clean_dist()
+{
+ pake_remove_dir(Builder::distDir());
+ $finder = pakeFinder::type('file')->name(Builder::distFiles());
+ pake_remove($finder, Builder::buildDir());
+}
+
+/**
+ * Creates the tarballs for a release
+ */
+function run_dist($task=null, $args=array(), $cliOpts=array())
+{
+ // copy workspace dir into dist dir, without git
+ pake_mkdirs(Builder::distDir());
+ $finder = pakeFinder::type('any')->ignore_version_control();
+ pake_mirror($finder, realpath(Builder::workspaceDir()), realpath(Builder::distDir()));
+
+ // remove unwanted files from dist dir
+
+ // also: do we still need to run dos2unix?
+
+ // create tarballs
+ $cwd = getcwd();
+ chdir(dirname(Builder::distDir()));
+ foreach(Builder::distFiles() as $distFile) {
+ // php can not really create good zip files via phar: they are not compressed!
+ if (substr($distFile, -4) == '.zip') {
+ $cmd = Builder::tool('zip');
+ $extra = '-9 -r';
+ pake_sh("$cmd $distFile $extra ".basename(Builder::distDir()));
+ }
+ else {
+ $finder = pakeFinder::type('any')->pattern(basename(Builder::distDir()).'/**');
+ // see https://bugs.php.net/bug.php?id=58852
+ $pharFile = str_replace(Builder::libVersion(), '_LIBVERSION_', $distFile);
+ pakeArchive::createArchive($finder, '.', $pharFile);
+ rename($pharFile, $distFile);
+ }
+ }
+ chdir($cwd);
+}
+
+function run_clean_workspace($task=null, $args=array(), $cliOpts=array())
+{
+ pake_remove_dir(Builder::workspaceDir());
+}
+
+/**
+ * Cleans up the whole build directory
+ * @todo 'make clean' usually just removes the results of the build, distclean removes all but sources
+ */
+function run_clean($task=null, $args=array(), $cliOpts=array())
+{
+ pake_remove_dir(Builder::buildDir());
+}
+
+// helper task: display help text
+pake_task( 'default' );
+// internal task: parse cli options
+pake_task('getopts');
+pake_task('init', 'getopts');
+pake_task('doc', 'getopts', 'init', 'clean-doc');
+pake_task('build', 'getopts', 'init', 'doc');
+pake_task('dist', 'getopts', 'init', 'build', 'clean-dist');
+pake_task('clean-doc', 'getopts');
+pake_task('clean-dist', 'getopts');
+pake_task('clean-workspace', 'getopts');
+pake_task('clean', 'getopts');
+
+}
diff --git a/php/phpxmlrpc/src/Autoloader.php b/php/phpxmlrpc/src/Autoloader.php
new file mode 100644
index 0000000..40ec219
--- /dev/null
+++ b/php/phpxmlrpc/src/Autoloader.php
@@ -0,0 +1,36 @@
+send().
+ */
+ public function __construct($path, $server = '', $port = '', $method = '')
+ {
+ // allow user to specify all params in $path
+ if ($server == '' and $port == '' and $method == '') {
+ $parts = parse_url($path);
+ $server = $parts['host'];
+ $path = isset($parts['path']) ? $parts['path'] : '';
+ if (isset($parts['query'])) {
+ $path .= '?' . $parts['query'];
+ }
+ if (isset($parts['fragment'])) {
+ $path .= '#' . $parts['fragment'];
+ }
+ if (isset($parts['port'])) {
+ $port = $parts['port'];
+ }
+ if (isset($parts['scheme'])) {
+ $method = $parts['scheme'];
+ }
+ if (isset($parts['user'])) {
+ $this->username = $parts['user'];
+ }
+ if (isset($parts['pass'])) {
+ $this->password = $parts['pass'];
+ }
+ }
+ if ($path == '' || $path[0] != '/') {
+ $this->path = '/' . $path;
+ } else {
+ $this->path = $path;
+ }
+ $this->server = $server;
+ if ($port != '') {
+ $this->port = $port;
+ }
+ if ($method != '') {
+ $this->method = $method;
+ }
+
+ // if ZLIB is enabled, let the client by default accept compressed responses
+ if (function_exists('gzinflate') || (
+ function_exists('curl_init') && (($info = curl_version()) &&
+ ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
+ )
+ ) {
+ $this->accepted_compression = array('gzip', 'deflate');
+ }
+
+ // keepalives: enabled by default
+ $this->keepalive = true;
+
+ // by default the xml parser can support these 3 charset encodings
+ $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
+
+ // Add all charsets which mbstring can handle, but remove junk not found in IANA registry at
+ // in http://www.iana.org/assignments/character-sets/character-sets.xhtml
+ // NB: this is disabled to avoid making all the requests sent huge... mbstring supports more than 80 charsets!
+ /*if (function_exists('mb_list_encodings')) {
+
+ $encodings = array_diff(mb_list_encodings(), array('pass', 'auto', 'wchar', 'BASE64', 'UUENCODE', 'ASCII',
+ 'HTML-ENTITIES', 'Quoted-Printable', '7bit','8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le'));
+ $this->accepted_charset_encodings = array_unique(array_merge($this->accepted_charset_encodings, $encodings));
+ }*/
+
+ // initialize user_agent string
+ $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion;
+ }
+
+ /**
+ * Enable/disable the echoing to screen of the xmlrpc responses received. The default is not no output anything.
+ *
+ * The debugging information at level 1 includes the raw data returned from the XML-RPC server it was querying
+ * (including bot HTTP headers and the full XML payload), and the PHP value the client attempts to create to
+ * represent the value returned by the server
+ * At level2, the complete payload of the xmlrpc request is also printed, before being sent t the server.
+ *
+ * This option can be very useful when debugging servers as it allows you to see exactly what the client sends and
+ * the server returns.
+ *
+ * @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
+ */
+ public function setDebug($level)
+ {
+ $this->debug = $level;
+ }
+
+ /**
+ * Sets the username and password for authorizing the client to the server.
+ *
+ * With the default (HTTP) transport, this information is used for HTTP Basic authorization.
+ * Note that username and password can also be set using the class constructor.
+ * With HTTP 1.1 and HTTPS transport, NTLM and Digest authentication protocols are also supported. To enable them use
+ * the constants CURLAUTH_DIGEST and CURLAUTH_NTLM as values for the auth type parameter.
+ *
+ * @param string $user username
+ * @param string $password password
+ * @param integer $authType auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC
+ * (basic auth). Note that auth types NTLM and Digest will only work if the Curl php
+ * extension is enabled.
+ */
+ public function setCredentials($user, $password, $authType = 1)
+ {
+ $this->username = $user;
+ $this->password = $password;
+ $this->authtype = $authType;
+ }
+
+ /**
+ * Set the optional certificate and passphrase used in SSL-enabled communication with a remote server.
+ *
+ * Note: to retrieve information about the client certificate on the server side, you will need to look into the
+ * environment variables which are set up by the webserver. Different webservers will typically set up different
+ * variables.
+ *
+ * @param string $cert the name of a file containing a PEM formatted certificate
+ * @param string $certPass the password required to use it
+ */
+ public function setCertificate($cert, $certPass = '')
+ {
+ $this->cert = $cert;
+ $this->certpass = $certPass;
+ }
+
+ /**
+ * Add a CA certificate to verify server with in SSL-enabled communication when SetSSLVerifypeer has been set to TRUE.
+ *
+ * See the php manual page about CURLOPT_CAINFO for more details.
+ *
+ * @param string $caCert certificate file name (or dir holding certificates)
+ * @param bool $isDir set to true to indicate cacert is a dir. defaults to false
+ */
+ public function setCaCertificate($caCert, $isDir = false)
+ {
+ if ($isDir) {
+ $this->cacertdir = $caCert;
+ } else {
+ $this->cacert = $caCert;
+ }
+ }
+
+ /**
+ * 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 the remote host's SSL certificate, and cause the connection to fail
+ * if the cert verification fails.
+ *
+ * By default, verification is enabled.
+ * To specify custom SSL certificates to validate the server with, use the setCaCertificate method.
+ *
+ * @param bool $i enable/disable verification of peer certificate
+ */
+ public function setSSLVerifyPeer($i)
+ {
+ $this->verifypeer = $i;
+ }
+
+ /**
+ * Set attributes for SSL communication: verify the remote host's SSL certificate's common name (CN).
+ *
+ * Note that support for value 1 has been removed in cURL 7.28.1
+ *
+ * @param int $i Set to 1 to only the existence of a CN, not that it matches
+ */
+ public function setSSLVerifyHost($i)
+ {
+ $this->verifyhost = $i;
+ }
+
+ /**
+ * Set attributes for SSL communication: SSL version to use. Best left at 0 (default value ): let cURL decide
+ *
+ * @param int $i
+ */
+ public function setSSLVersion($i)
+ {
+ $this->sslversion = $i;
+ }
+
+ /**
+ * Set proxy info.
+ *
+ * NB: CURL versions before 7.11.10 cannot use a proxy to communicate with https servers.
+ *
+ * @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 defaults to CURLAUTH_BASIC (Basic authentication protocol); set to constant CURLAUTH_NTLM
+ * to use NTLM auth with proxy (has effect only when the client uses the HTTP 1.1 protocol)
+ */
+ public function setProxy($proxyHost, $proxyPort, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1)
+ {
+ $this->proxy = $proxyHost;
+ $this->proxyport = $proxyPort;
+ $this->proxy_user = $proxyUsername;
+ $this->proxy_pass = $proxyPassword;
+ $this->proxy_authtype = $proxyAuthType;
+ }
+
+ /**
+ * Enables/disables reception of compressed xmlrpc responses.
+ *
+ * This requires the "zlib" extension to be enabled in your php install. If it is, by default xmlrpc_client
+ * instances will enable reception of compressed content.
+ * 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');
+ } elseif ($compMethod == false) {
+ $this->accepted_compression = array();
+ } else {
+ $this->accepted_compression = array($compMethod);
+ }
+ }
+
+ /**
+ * Enables/disables http compression of xmlrpc request.
+ *
+ * This requires the "zlib" extension to be enabled in your php install.
+ * 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 with every further request (useful e.g. for keeping
+ * session info outside of the xml-rpc payload).
+ *
+ * NB: By default cookies are sent using the 'original/netscape' format, which is also the same as the RFC 2965;
+ * setting any param but name and value will turn the cookie into a 'version 1' cookie (i.e. RFC 2109 cookie) that
+ * might not be fully supported by the server. Note that RFC 2109 has currently 'historic' status...
+ *
+ * @param string $name nb: will not be escaped in the request's http headers. Take care not to use CTL chars or
+ * separators!
+ * @param string $value
+ * @param string $path leave this empty unless the xml-rpc server only accepts RFC 2109 cookies
+ * @param string $domain leave this empty unless the xml-rpc server only accepts RFC 2109 cookies
+ * @param int $port leave this empty unless the xml-rpc server only accepts RFC 2109 cookies
+ *
+ * @todo check correctness of urlencoding cookie value (copied from php way of doing it, but php is generally sending
+ * response not requests. We do the opposite...)
+ * @todo strip invalid chars from cookie name? As per RFC6265, we should follow RFC2616, Section 2.2
+ */
+ public function setCookie($name, $value = '', $path = '', $domain = '', $port = null)
+ {
+ $this->cookies[$name]['value'] = urlencode($value);
+ if ($path || $domain || $port) {
+ $this->cookies[$name]['path'] = $path;
+ $this->cookies[$name]['domain'] = $domain;
+ $this->cookies[$name]['port'] = $port;
+ $this->cookies[$name]['version'] = 1;
+ } else {
+ $this->cookies[$name]['version'] = 0;
+ }
+ }
+
+ /**
+ * Directly set cURL options, for extra flexibility (when in cURL mode).
+ *
+ * It allows eg. to bind client to a specific IP interface / address.
+ *
+ * @param array $options
+ */
+ public 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.
+ *
+ * The default user agent string includes the name of this library and the version number.
+ *
+ * @param string $agentString
+ */
+ public function setUserAgent($agentString)
+ {
+ $this->user_agent = $agentString;
+ }
+
+ /**
+ * Send an xmlrpc request to the server.
+ *
+ * @param Request|Request[]|string $req The Request object, or an array of requests for using multicall, or the
+ * complete xml representation of a request.
+ * When sending an array of Request objects, the client will try to make use of
+ * a single 'system.multicall' xml-rpc method call to forward to the server all
+ * the requests in a single HTTP round trip, unless $this->no_multicall has
+ * been previously set to TRUE (see the multicall method below), in which case
+ * many consecutive xmlrpc requests will be sent. The method will return an
+ * array of Response objects in both cases.
+ * The third variant allows to build by hand (or any other means) a complete
+ * xmlrpc request message, and send it to the server. $req should be a string
+ * containing the complete xml representation of the request. It is e.g. useful
+ * when, for maximal speed of execution, the request is serialized into a
+ * string using the native php xmlrpc functions (see http://www.php.net/xmlrpc)
+ * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply.
+ * This timeout value is passed to fsockopen(). It is also used for detecting server
+ * timeouts during communication (i.e. if the server does not send anything to the client
+ * for $timeout seconds, the connection will be closed).
+ * @param string $method valid values are 'http', 'http11' and 'https'. If left unspecified, the http protocol
+ * chosen during creation of the object will be used.
+ *
+ *
+ * @return Response|Response[] Note that the client will always return a Response object, even if the call fails
+ */
+ public function send($req, $timeout = 0, $method = '')
+ {
+ // if user does not specify http protocol, use native method of this client
+ // (i.e. method set during call to constructor)
+ if ($method == '') {
+ $method = $this->method;
+ }
+
+ if (is_array($req)) {
+ // $req is an array of Requests
+ $r = $this->multicall($req, $timeout, $method);
+
+ return $r;
+ } elseif (is_string($req)) {
+ $n = new Request('');
+ $n->payload = $req;
+ $req = $n;
+ }
+
+ // where req is a Request
+ $req->setDebug($this->debug);
+
+ if ($method == 'https') {
+ $r = $this->sendPayloadHTTPS(
+ $req,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ $this->cert,
+ $this->certpass,
+ $this->cacert,
+ $this->cacertdir,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype,
+ $this->keepalive,
+ $this->key,
+ $this->keypass,
+ $this->sslversion
+ );
+ } elseif ($method == 'http11') {
+ $r = $this->sendPayloadCURL(
+ $req,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ null,
+ null,
+ null,
+ null,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype,
+ 'http',
+ $this->keepalive
+ );
+ } else {
+ $r = $this->sendPayloadHTTP10(
+ $req,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype,
+ $method
+ );
+ }
+
+ return $r;
+ }
+
+ /**
+ * @param Request $req
+ * @param string $server
+ * @param int $port
+ * @param int $timeout
+ * @param string $username
+ * @param string $password
+ * @param int $authType
+ * @param string $proxyHost
+ * @param int $proxyPort
+ * @param string $proxyUsername
+ * @param string $proxyPassword
+ * @param int $proxyAuthType
+ * @param string $method
+ * @return Response
+ */
+ protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '',
+ $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1,
+ $method='http')
+ {
+ if ($port == 0) {
+ $port = ( $method === "https" ) ? 443 : 80;
+ }
+
+ // Only create the payload if it was not created previously
+ if (empty($req->payload)) {
+ $req->createPayload($this->request_charset_encoding);
+ }
+
+ $payload = $req->payload;
+ // Deflate request body and set appropriate request headers
+ if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
+ if ($this->request_compression == 'gzip') {
+ $a = @gzencode($payload);
+ if ($a) {
+ $payload = $a;
+ $encodingHdr = "Content-Encoding: gzip\r\n";
+ }
+ } else {
+ $a = @gzcompress($payload);
+ if ($a) {
+ $payload = $a;
+ $encodingHdr = "Content-Encoding: deflate\r\n";
+ }
+ }
+ } else {
+ $encodingHdr = '';
+ }
+
+ // thanks to Grant Rauscher for this
+ $credentials = '';
+ if ($username != '') {
+ $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
+ if ($authType != 1) {
+ error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
+ }
+ }
+
+ $acceptedEncoding = '';
+ if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
+ $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
+ }
+
+ $proxyCredentials = '';
+ if ($proxyHost) {
+ if ($proxyPort == 0) {
+ $proxyPort = 8080;
+ }
+ $connectServer = $proxyHost;
+ $connectPort = $proxyPort;
+ $transport = "tcp";
+ $uri = 'http://' . $server . ':' . $port . $this->path;
+ if ($proxyUsername != '') {
+ if ($proxyAuthType != 1) {
+ error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
+ }
+ $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n";
+ }
+ } else {
+ $connectServer = $server;
+ $connectPort = $port;
+ /// @todo if supporting https, we should support all its current options as well: peer name verification etc...
+ $transport = ( $method === "https" ) ? "tls" : "tcp";
+ $uri = $this->path;
+ }
+
+ // Cookie generation, as per rfc2965 (version 1 cookies) or
+ // netscape's rules (version 0 cookies)
+ $cookieHeader = '';
+ if (count($this->cookies)) {
+ $version = '';
+ foreach ($this->cookies as $name => $cookie) {
+ if ($cookie['version']) {
+ $version = ' $Version="' . $cookie['version'] . '";';
+ $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";';
+ if ($cookie['path']) {
+ $cookieHeader .= ' $Path="' . $cookie['path'] . '";';
+ }
+ if ($cookie['domain']) {
+ $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";';
+ }
+ if ($cookie['port']) {
+ $cookieHeader .= ' $Port="' . $cookie['port'] . '";';
+ }
+ } else {
+ $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";";
+ }
+ }
+ $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" .
+ $credentials .
+ $proxyCredentials .
+ $acceptedEncoding .
+ $encodingHdr .
+ 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
+ $cookieHeader .
+ 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " .
+ strlen($payload) . "\r\n\r\n" .
+ $payload;
+
+ if ($this->debug > 1) {
+ Logger::instance()->debugMessage("---SENDING---\n$op\n---END---");
+ }
+
+ if ($timeout > 0) {
+ $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $timeout);
+ } else {
+ $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr);
+ }
+ if ($fp) {
+ if ($timeout > 0) {
+ stream_set_timeout($fp, $timeout);
+ }
+ } else {
+ $this->errstr = 'Connect error: ' . $this->errstr;
+ $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')');
+
+ return $r;
+ }
+
+ if (!fputs($fp, $op, strlen($op))) {
+ fclose($fp);
+ $this->errstr = 'Write error';
+ $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr);
+
+ return $r;
+ } else {
+ // reset errno and errstr on successful socket connection
+ $this->errstr = '';
+ }
+ // G. Giunta 2005/10/24: close socket before parsing.
+ // should yield slightly better execution times, and make easier recursive calls (e.g. to follow http redirects)
+ $ipd = '';
+ do {
+ // shall we check for $data === FALSE?
+ // as per the manual, it signals an error
+ $ipd .= fread($fp, 32768);
+ } while (!feof($fp));
+ fclose($fp);
+ $r = $req->parseResponse($ipd, false, $this->return_type);
+
+ return $r;
+ }
+
+ /**
+ * @param Request $req
+ * @param string $server
+ * @param int $port
+ * @param int $timeout
+ * @param string $username
+ * @param string $password
+ * @param int $authType
+ * @param string $cert
+ * @param string $certPass
+ * @param string $caCert
+ * @param string $caCertDir
+ * @param string $proxyHost
+ * @param int $proxyPort
+ * @param string $proxyUsername
+ * @param string $proxyPassword
+ * @param int $proxyAuthType
+ * @param bool $keepAlive
+ * @param string $key
+ * @param string $keyPass
+ * @param int $sslVersion
+ * @return Response
+ */
+ protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '',
+ $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
+ $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '',
+ $sslVersion = 0)
+ {
+ return $this->sendPayloadCURL($req, $server, $port, $timeout, $username,
+ $password, $authType, $cert, $certPass, $caCert, $caCertDir, $proxyHost, $proxyPort,
+ $proxyUsername, $proxyPassword, $proxyAuthType, 'https', $keepAlive, $key, $keyPass, $sslVersion);
+ }
+
+ /**
+ * Contributed by Justin Miller
+ * Requires curl to be built into PHP
+ * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
+ *
+ * @param Request $req
+ * @param string $server
+ * @param int $port
+ * @param int $timeout
+ * @param string $username
+ * @param string $password
+ * @param int $authType
+ * @param string $cert
+ * @param string $certPass
+ * @param string $caCert
+ * @param string $caCertDir
+ * @param string $proxyHost
+ * @param int $proxyPort
+ * @param string $proxyUsername
+ * @param string $proxyPassword
+ * @param int $proxyAuthType
+ * @param string $method
+ * @param bool $keepAlive
+ * @param string $key
+ * @param string $keyPass
+ * @param int $sslVersion
+ * @return Response
+ */
+ protected function sendPayloadCURL($req, $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 = '', $sslVersion = 0)
+ {
+ if (!function_exists('curl_init')) {
+ $this->errstr = 'CURL unavailable on this install';
+ return new Response(0, PhpXmlRpc::$xmlrpcerr['no_curl'], PhpXmlRpc::$xmlrpcstr['no_curl']);
+ }
+ if ($method == 'https') {
+ if (($info = curl_version()) &&
+ ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))
+ ) {
+ $this->errstr = 'SSL unavailable on this install';
+ return new Response(0, PhpXmlRpc::$xmlrpcerr['no_ssl'], PhpXmlRpc::$xmlrpcstr['no_ssl']);
+ }
+ }
+
+ if ($port == 0) {
+ if ($method == 'http') {
+ $port = 80;
+ } else {
+ $port = 443;
+ }
+ }
+
+ // Only create the payload if it was not created previously
+ if (empty($req->payload)) {
+ $req->createPayload($this->request_charset_encoding);
+ }
+
+ // Deflate request body and set appropriate request headers
+ $payload = $req->payload;
+ if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
+ if ($this->request_compression == 'gzip') {
+ $a = @gzencode($payload);
+ if ($a) {
+ $payload = $a;
+ $encodingHdr = 'Content-Encoding: gzip';
+ }
+ } else {
+ $a = @gzcompress($payload);
+ if ($a) {
+ $payload = $a;
+ $encodingHdr = 'Content-Encoding: deflate';
+ }
+ }
+ } else {
+ $encodingHdr = '';
+ }
+
+ if ($this->debug > 1) {
+ Logger::instance()->debugMessage("---SENDING---\n$payload\n---END---");
+ }
+
+ if (!$keepAlive || !$this->xmlrpc_curl_handle) {
+ $curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
+ if ($keepAlive) {
+ $this->xmlrpc_curl_handle = $curl;
+ }
+ } else {
+ $curl = $this->xmlrpc_curl_handle;
+ }
+
+ // results into variable
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+
+ if ($this->debug > 1) {
+ curl_setopt($curl, CURLOPT_VERBOSE, true);
+ /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered
+ }
+ curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
+ // required for XMLRPC: post the data
+ curl_setopt($curl, CURLOPT_POST, 1);
+ // the data
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
+
+ // return the header too
+ curl_setopt($curl, CURLOPT_HEADER, 1);
+
+ // 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...
+ if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
+ //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
+ // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if (count($this->accepted_compression) == 1) {
+ curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
+ } else {
+ curl_setopt($curl, CURLOPT_ENCODING, '');
+ }
+ }
+ // extra headers
+ $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
+ // if no keepalive is wanted, let the server know it in advance
+ if (!$keepAlive) {
+ $headers[] = 'Connection: close';
+ }
+ // request compression header
+ if ($encodingHdr) {
+ $headers[] = $encodingHdr;
+ }
+
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ // timeout is borked
+ if ($timeout) {
+ curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
+ }
+
+ if ($username && $password) {
+ curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
+ if (defined('CURLOPT_HTTPAUTH')) {
+ curl_setopt($curl, CURLOPT_HTTPAUTH, $authType);
+ } elseif ($authType != 1) {
+ error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
+ }
+ }
+
+ if ($method == 'https') {
+ // set cert file
+ if ($cert) {
+ curl_setopt($curl, CURLOPT_SSLCERT, $cert);
+ }
+ // set cert password
+ if ($certPass) {
+ curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certPass);
+ }
+ // whether to verify remote host's cert
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
+ // set ca certificates file/dir
+ if ($caCert) {
+ curl_setopt($curl, CURLOPT_CAINFO, $caCert);
+ }
+ if ($caCertDir) {
+ curl_setopt($curl, CURLOPT_CAPATH, $caCertDir);
+ }
+ // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if ($key) {
+ curl_setopt($curl, CURLOPT_SSLKEY, $key);
+ }
+ // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if ($keyPass) {
+ curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keyPass);
+ }
+ // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);
+ // allow usage of different SSL versions
+ curl_setopt($curl, CURLOPT_SSLVERSION, $sslVersion);
+ }
+
+ // proxy info
+ if ($proxyHost) {
+ if ($proxyPort == 0) {
+ $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080
+ }
+ curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
+ if ($proxyUsername) {
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword);
+ if (defined('CURLOPT_PROXYAUTH')) {
+ curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType);
+ } elseif ($proxyAuthType != 1) {
+ error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
+ }
+ }
+ }
+
+ // NB: should we build cookie http headers by hand rather than let CURL do it?
+ // the following code does not honour 'expires', 'path' and 'domain' cookie attributes
+ // set to client obj the the user...
+ if (count($this->cookies)) {
+ $cookieHeader = '';
+ foreach ($this->cookies as $name => $cookie) {
+ $cookieHeader .= $name . '=' . $cookie['value'] . '; ';
+ }
+ curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2));
+ }
+
+ foreach ($this->extracurlopts as $opt => $val) {
+ curl_setopt($curl, $opt, $val);
+ }
+
+ $result = curl_exec($curl);
+
+ if ($this->debug > 1) {
+ $message = "---CURL INFO---\n";
+ foreach (curl_getinfo($curl) as $name => $val) {
+ if (is_array($val)) {
+ $val = implode("\n", $val);
+ }
+ $message .= $name . ': ' . $val . "\n";
+ }
+ $message .= "---END---";
+ Logger::instance()->debugMessage($message);
+ }
+
+ if (!$result) {
+ /// @todo we should use a better check here - what if we get back '' or '0'?
+
+ $this->errstr = 'no response';
+ $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl));
+ curl_close($curl);
+ if ($keepAlive) {
+ $this->xmlrpc_curl_handle = null;
+ }
+ } else {
+ if (!$keepAlive) {
+ curl_close($curl);
+ }
+ $resp = $req->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() == PhpXmlRpc::$xmlrpcerr['http_error'] && $keepAlive) {
+ curl_close($curl);
+ $this->xmlrpc_curl_handle = null;
+ }
+ }
+
+ return $resp;
+ }
+
+ /**
+ * Send an array of requests 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 Request[] $reqs an array of Request objects
+ * @param integer $timeout connection timeout (in seconds). See the details in the docs for the send() method
+ * @param string $method the http protocol variant to be used. See the details in the docs for the send() method
+ * @param boolean fallback When true, upon receiving an error during multicall, multiple single calls will be
+ * attempted
+ *
+ * @return Response[]
+ */
+ public function multicall($reqs, $timeout = 0, $method = '', $fallback = true)
+ {
+ if ($method == '') {
+ $method = $this->method;
+ }
+ if (!$this->no_multicall) {
+ $results = $this->_try_multicall($reqs, $timeout, $method);
+ if (is_array($results)) {
+ // System.multicall succeeded
+ return $results;
+ } else {
+ // either system.multicall is unsupported by server,
+ // or call failed for some other reason.
+ if ($fallback) {
+ // Don't try it next time...
+ $this->no_multicall = true;
+ } else {
+ if (is_a($results, '\PhpXmlRpc\Response')) {
+ $result = $results;
+ } else {
+ $result = new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], PhpXmlRpc::$xmlrpcstr['multicall_error']);
+ }
+ }
+ }
+ } else {
+ // override fallback, in case careless user tries to do two
+ // opposite things at the same time
+ $fallback = true;
+ }
+
+ $results = array();
+ if ($fallback) {
+ // system.multicall is (probably) unsupported by server:
+ // emulate multicall via multiple requests
+ foreach ($reqs as $req) {
+ $results[] = $this->send($req, $timeout, $method);
+ }
+ } else {
+ // user does NOT want to fallback on many single calls:
+ // since we should always return an array of responses,
+ // return an array with the same error repeated n times
+ foreach ($reqs as $req) {
+ $results[] = $result;
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Attempt to boxcar $reqs via system.multicall.
+ *
+ * Returns either an array of Response, a single error Response or false (when received response does not respect
+ * valid multicall syntax).
+ *
+ * @param Request[] $reqs
+ * @param int $timeout
+ * @param string $method
+ * @return Response[]|bool|mixed|Response
+ */
+ private function _try_multicall($reqs, $timeout, $method)
+ {
+ // Construct multicall request
+ $calls = array();
+ foreach ($reqs as $req) {
+ $call['methodName'] = new Value($req->method(), 'string');
+ $numParams = $req->getNumParams();
+ $params = array();
+ for ($i = 0; $i < $numParams; $i++) {
+ $params[$i] = $req->getParam($i);
+ }
+ $call['params'] = new Value($params, 'array');
+ $calls[] = new Value($call, 'struct');
+ }
+ $multiCall = new Request('system.multicall');
+ $multiCall->addParam(new Value($calls, 'array'));
+
+ // Attempt RPC call
+ $result = $this->send($multiCall, $timeout, $method);
+
+ if ($result->faultCode() != 0) {
+ // call to system.multicall failed
+ return $result;
+ }
+
+ // Unpack responses.
+ $rets = $result->value();
+
+ if ($this->return_type == 'xml') {
+ return $rets;
+ } elseif ($this->return_type == 'phpvals') {
+ /// @todo test this code branch...
+ $rets = $result->value();
+ if (!is_array($rets)) {
+ return false; // bad return type from system.multicall
+ }
+ $numRets = count($rets);
+ if ($numRets != count($reqs)) {
+ return false; // wrong number of return values.
+ }
+
+ $response = array();
+ for ($i = 0; $i < $numRets; $i++) {
+ $val = $rets[$i];
+ if (!is_array($val)) {
+ return false;
+ }
+ switch (count($val)) {
+ case 1:
+ if (!isset($val[0])) {
+ return false; // Bad value
+ }
+ // Normal return value
+ $response[$i] = new Response($val[0], 0, '', 'phpvals');
+ break;
+ case 2:
+ /// @todo remove usage of @: it is apparently quite slow
+ $code = @$val['faultCode'];
+ if (!is_int($code)) {
+ return false;
+ }
+ $str = @$val['faultString'];
+ if (!is_string($str)) {
+ return false;
+ }
+ $response[$i] = new Response(0, $code, $str);
+ break;
+ default:
+ return false;
+ }
+ }
+
+ return $response;
+ } else {
+ // return type == 'xmlrpcvals'
+
+ $rets = $result->value();
+ if ($rets->kindOf() != 'array') {
+ return false; // bad return type from system.multicall
+ }
+ $numRets = $rets->count();
+ if ($numRets != count($reqs)) {
+ return false; // wrong number of return values.
+ }
+
+ $response = array();
+ foreach($rets as $val) {
+ switch ($val->kindOf()) {
+ case 'array':
+ if ($val->count() != 1) {
+ return false; // Bad value
+ }
+ // Normal return value
+ $response[] = new Response($val[0]);
+ break;
+ case 'struct':
+ $code = $val['faultCode'];
+ if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') {
+ return false;
+ }
+ $str = $val['faultString'];
+ if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') {
+ return false;
+ }
+ $response[] = new Response(0, $code->scalarval(), $str->scalarval());
+ break;
+ default:
+ return false;
+ }
+ }
+
+ return $response;
+ }
+ }
+}
diff --git a/php/phpxmlrpc/src/Encoder.php b/php/phpxmlrpc/src/Encoder.php
new file mode 100644
index 0000000..dfec15d
--- /dev/null
+++ b/php/phpxmlrpc/src/Encoder.php
@@ -0,0 +1,317 @@
+kindOf()) {
+ case 'scalar':
+ if (in_array('extension_api', $options)) {
+ reset($xmlrpcVal->me);
+ list($typ, $val) = each($xmlrpcVal->me);
+ switch ($typ) {
+ case 'dateTime.iso8601':
+ $xmlrpcVal->scalar = $val;
+ $xmlrpcVal->type = 'datetime';
+ $xmlrpcVal->timestamp = \PhpXmlRpc\Helper\Date::iso8601Decode($val);
+
+ return $xmlrpcVal;
+ case 'base64':
+ $xmlrpcVal->scalar = $val;
+ $xmlrpcVal->type = $typ;
+
+ return $xmlrpcVal;
+ default:
+ return $xmlrpcVal->scalarval();
+ }
+ }
+ if (in_array('dates_as_objects', $options) && $xmlrpcVal->scalartyp() == 'dateTime.iso8601') {
+ // we return a Datetime object instead of a string
+ // since now the constructor of xmlrpc value accepts safely strings, ints and datetimes,
+ // we cater to all 3 cases here
+ $out = $xmlrpcVal->scalarval();
+ if (is_string($out)) {
+ $out = strtotime($out);
+ }
+ if (is_int($out)) {
+ $result = new \DateTime();
+ $result->setTimestamp($out);
+
+ return $result;
+ } elseif (is_a($out, 'DateTimeInterface')) {
+ return $out;
+ }
+ }
+
+ return $xmlrpcVal->scalarval();
+ case 'array':
+ $arr = array();
+ foreach($xmlrpcVal as $value) {
+ $arr[] = $this->decode($value, $options);
+ }
+
+ return $arr;
+ case 'struct':
+ // If user said so, try to rebuild php objects for specific struct vals.
+ /// @todo should we raise a warning for class not found?
+ // shall we check for proper subclass of xmlrpc value instead of
+ // presence of _php_class to detect what we can do?
+ if (in_array('decode_php_objs', $options) && $xmlrpcVal->_php_class != ''
+ && class_exists($xmlrpcVal->_php_class)
+ ) {
+ $obj = @new $xmlrpcVal->_php_class();
+ foreach ($xmlrpcVal as $key => $value) {
+ $obj->$key = $this->decode($value, $options);
+ }
+
+ return $obj;
+ } else {
+ $arr = array();
+ foreach ($xmlrpcVal as $key => $value) {
+ $arr[$key] = $this->decode($value, $options);
+ }
+
+ return $arr;
+ }
+ case 'msg':
+ $paramCount = $xmlrpcVal->getNumParams();
+ $arr = array();
+ for ($i = 0; $i < $paramCount; $i++) {
+ $arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
+ }
+
+ return $arr;
+ }
+ }
+
+ /**
+ * Takes native php types and encodes them into xmlrpc PHP object format.
+ * It will not re-encode xmlrpc value objects.
+ *
+ * Feature creep -- could support more types via optional type argument
+ * (string => datetime support has been added, ??? => base64 not yet)
+ *
+ * If given a proper options parameter, php object instances will be encoded
+ * into 'special' xmlrpc values, that can later be decoded into php objects
+ * by calling php_xmlrpc_decode() with a corresponding option
+ *
+ * @author Dan Libby (dan@libby.com)
+ *
+ * @param mixed $phpVal the value to be converted into an xmlrpc value object
+ * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
+ *
+ * @return \PhpXmlrpc\Value
+ */
+ public function encode($phpVal, $options = array())
+ {
+ $type = gettype($phpVal);
+ switch ($type) {
+ case 'string':
+ if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $phpVal)) {
+ $xmlrpcVal = new Value($phpVal, Value::$xmlrpcDateTime);
+ } else {
+ $xmlrpcVal = new Value($phpVal, Value::$xmlrpcString);
+ }
+ break;
+ case 'integer':
+ $xmlrpcVal = new Value($phpVal, Value::$xmlrpcInt);
+ break;
+ case 'double':
+ $xmlrpcVal = new Value($phpVal, Value::$xmlrpcDouble);
+ break;
+ //
+ // Add support for encoding/decoding of booleans, since they are supported in PHP
+ case 'boolean':
+ $xmlrpcVal = new Value($phpVal, Value::$xmlrpcBoolean);
+ break;
+ //
+ case 'array':
+ // PHP arrays can be encoded to either xmlrpc structs or arrays,
+ // depending on wheter they are hashes or plain 0..n integer indexed
+ // A shorter one-liner would be
+ // $tmp = array_diff(array_keys($phpVal), range(0, count($phpVal)-1));
+ // but execution time skyrockets!
+ $j = 0;
+ $arr = array();
+ $ko = false;
+ foreach ($phpVal as $key => $val) {
+ $arr[$key] = $this->encode($val, $options);
+ if (!$ko && $key !== $j) {
+ $ko = true;
+ }
+ $j++;
+ }
+ if ($ko) {
+ $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
+ } else {
+ $xmlrpcVal = new Value($arr, Value::$xmlrpcArray);
+ }
+ break;
+ case 'object':
+ if (is_a($phpVal, 'PhpXmlRpc\Value')) {
+ $xmlrpcVal = $phpVal;
+ } elseif (is_a($phpVal, 'DateTimeInterface')) {
+ $xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
+ } else {
+ $arr = array();
+ reset($phpVal);
+ while (list($k, $v) = each($phpVal)) {
+ $arr[$k] = $this->encode($v, $options);
+ }
+ $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
+ if (in_array('encode_php_objs', $options)) {
+ // let's save original class name into xmlrpc value:
+ // might be useful later on...
+ $xmlrpcVal->_php_class = get_class($phpVal);
+ }
+ }
+ break;
+ case 'NULL':
+ if (in_array('extension_api', $options)) {
+ $xmlrpcVal = new Value('', Value::$xmlrpcString);
+ } elseif (in_array('null_extension', $options)) {
+ $xmlrpcVal = new Value('', Value::$xmlrpcNull);
+ } else {
+ $xmlrpcVal = new Value();
+ }
+ break;
+ case 'resource':
+ if (in_array('extension_api', $options)) {
+ $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt);
+ } else {
+ $xmlrpcVal = new Value();
+ }
+ // catch "user function", "unknown type"
+ default:
+ // giancarlo pinerolo
+ // it has to return
+ // an empty object in case, not a boolean.
+ $xmlrpcVal = new Value();
+ break;
+ }
+
+ return $xmlrpcVal;
+ }
+
+ /**
+ * Convert the xml representation of a method response, method request or single
+ * xmlrpc value into the appropriate object (a.k.a. deserialize).
+ *
+ * @param string $xmlVal
+ * @param array $options
+ *
+ * @return mixed false on error, or an instance of either Value, Request or Response
+ */
+ public function decodeXml($xmlVal, $options = array())
+ {
+ // 'guestimate' encoding
+ $valEncoding = XMLParser::guessEncoding('', $xmlVal);
+ if ($valEncoding != '') {
+
+ // Since parsing will fail if charset is not specified in the xml prologue,
+ // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that...
+ // The following code might be better for mb_string enabled installs, but
+ // makes the lib about 200% slower...
+ //if (!is_valid_charset($valEncoding, array('UTF-8'))
+ if (!in_array($valEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($xmlVal)) {
+ if ($valEncoding == 'ISO-8859-1') {
+ $xmlVal = utf8_encode($xmlVal);
+ } else {
+ if (extension_loaded('mbstring')) {
+ $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding);
+ } else {
+ error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
+ }
+ }
+ }
+ }
+
+ $parser = xml_parser_create();
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ // What if internal encoding is not in one of the 3 allowed?
+ // we use the broadest one, ie. utf8!
+ if (!in_array(PhpXmlRpc::$xmlrpc_internalencoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
+ } else {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, PhpXmlRpc::$xmlrpc_internalencoding);
+ }
+
+ $xmlRpcParser = new XMLParser();
+ xml_set_object($parser, $xmlRpcParser);
+
+ xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee');
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
+ xml_set_default_handler($parser, 'xmlrpc_dh');
+ if (!xml_parse($parser, $xmlVal, 1)) {
+ $errstr = sprintf('XML error: %s at line %d, column %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser));
+ error_log($errstr);
+ xml_parser_free($parser);
+
+ return false;
+ }
+ xml_parser_free($parser);
+ if ($xmlRpcParser->_xh['isf'] > 1) {
+ // test that $xmlrpc->_xh['value'] is an obj, too???
+
+ error_log($xmlRpcParser->_xh['isf_reason']);
+
+ return false;
+ }
+ switch ($xmlRpcParser->_xh['rt']) {
+ case 'methodresponse':
+ $v = &$xmlRpcParser->_xh['value'];
+ if ($xmlRpcParser->_xh['isf'] == 1) {
+ $vc = $v['faultCode'];
+ $vs = $v['faultString'];
+ $r = new Response(0, $vc->scalarval(), $vs->scalarval());
+ } else {
+ $r = new Response($v);
+ }
+
+ return $r;
+ case 'methodcall':
+ $req = new Request($xmlRpcParser->_xh['method']);
+ for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
+ $req->addParam($xmlRpcParser->_xh['params'][$i]);
+ }
+
+ return $req;
+ case 'value':
+ return $xmlRpcParser->_xh['value'];
+ default:
+ return false;
+ }
+ }
+
+}
diff --git a/php/phpxmlrpc/src/Helper/Charset.php b/php/phpxmlrpc/src/Helper/Charset.php
new file mode 100644
index 0000000..4f1103b
--- /dev/null
+++ b/php/phpxmlrpc/src/Helper/Charset.php
@@ -0,0 +1,273 @@
+ array(), "out" => array());
+ protected $xml_iso88591_utf8 = array("in" => array(), "out" => array());
+
+ /// @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 (though no luck when receiving them...)
+ /*
+ protected $xml_cp1252_Entities = array('in' => array(), out' => array(
+ '€', '?', '‚', 'ƒ',
+ '„', '…', '†', '‡',
+ 'ˆ', '‰', 'Š', '‹',
+ 'Œ', '?', 'Ž', '?',
+ '?', '‘', '’', '“',
+ '”', '•', '–', '—',
+ '˜', '™', 'š', '›',
+ 'œ', '?', 'ž', 'Ÿ'
+ ));
+ */
+
+ protected $charset_supersets = array(
+ 'US-ASCII' => array('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
+ 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8',
+ 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12',
+ 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
+ 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN',),
+ );
+
+ protected static $instance = null;
+
+ /**
+ * This class is singleton for performance reasons.
+ *
+ * @return Charset
+ */
+ public static function instance()
+ {
+ if (self::$instance === null) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+
+ private function __construct()
+ {
+ for ($i = 0; $i < 32; $i++) {
+ $this->xml_iso88591_Entities["in"][] = chr($i);
+ $this->xml_iso88591_Entities["out"][] = "{$i};";
+ }
+
+ for ($i = 160; $i < 256; $i++) {
+ $this->xml_iso88591_Entities["in"][] = chr($i);
+ $this->xml_iso88591_Entities["out"][] = "{$i};";
+ }
+
+ /*for ($i = 128; $i < 160; $i++)
+ {
+ $this->xml_cp1252_Entities['in'][] = chr($i);
+ }*/
+ }
+
+ /**
+ * 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
+ *
+ * @param string $data
+ * @param string $srcEncoding
+ * @param string $destEncoding
+ *
+ * @return string
+ */
+ public function encodeEntities($data, $srcEncoding = '', $destEncoding = '')
+ {
+ if ($srcEncoding == '') {
+ // lame, but we know no better...
+ $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding;
+ }
+
+ $conversion = strtoupper($srcEncoding . '_' . $destEncoding);
+ switch ($conversion) {
+ case 'ISO-8859-1_':
+ case 'ISO-8859-1_US-ASCII':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escapedData = str_replace($this->xml_iso88591_Entities['in'], $this->xml_iso88591_Entities['out'], $escapedData);
+ break;
+
+ case 'ISO-8859-1_UTF-8':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escapedData = utf8_encode($escapedData);
+ break;
+
+ case 'ISO-8859-1_ISO-8859-1':
+ case 'US-ASCII_US-ASCII':
+ case 'US-ASCII_UTF-8':
+ case 'US-ASCII_':
+ case 'US-ASCII_ISO-8859-1':
+ case 'UTF-8_UTF-8':
+ //case 'CP1252_CP1252':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ break;
+
+ case 'UTF-8_':
+ case 'UTF-8_US-ASCII':
+ case 'UTF-8_ISO-8859-1':
+ // NB: this will choke on invalid UTF-8, going most likely beyond EOF
+ $escapedData = '';
+ // be kind to users creating string xmlrpc values out of different php types
+ $data = (string)$data;
+ $ns = strlen($data);
+ for ($nn = 0; $nn < $ns; $nn++) {
+ $ch = $data[$nn];
+ $ii = ord($ch);
+ // 7 bits: 0bbbbbbb (127)
+ if ($ii < 128) {
+ /// @todo shall we replace this with a (supposedly) faster str_replace?
+ switch ($ii) {
+ case 34:
+ $escapedData .= '"';
+ break;
+ case 38:
+ $escapedData .= '&';
+ break;
+ case 39:
+ $escapedData .= ''';
+ break;
+ case 60:
+ $escapedData .= '<';
+ break;
+ case 62:
+ $escapedData .= '>';
+ break;
+ default:
+ $escapedData .= $ch;
+ } // switch
+ } // 11 bits: 110bbbbb 10bbbbbb (2047)
+ elseif ($ii >> 5 == 6) {
+ $b1 = ($ii & 31);
+ $ii = ord($data[$nn + 1]);
+ $b2 = ($ii & 63);
+ $ii = ($b1 * 64) + $b2;
+ $ent = sprintf('%d;', $ii);
+ $escapedData .= $ent;
+ $nn += 1;
+ } // 16 bits: 1110bbbb 10bbbbbb 10bbbbbb
+ elseif ($ii >> 4 == 14) {
+ $b1 = ($ii & 15);
+ $ii = ord($data[$nn + 1]);
+ $b2 = ($ii & 63);
+ $ii = ord($data[$nn + 2]);
+ $b3 = ($ii & 63);
+ $ii = ((($b1 * 64) + $b2) * 64) + $b3;
+ $ent = sprintf('%d;', $ii);
+ $escapedData .= $ent;
+ $nn += 2;
+ } // 21 bits: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
+ elseif ($ii >> 3 == 30) {
+ $b1 = ($ii & 7);
+ $ii = ord($data[$nn + 1]);
+ $b2 = ($ii & 63);
+ $ii = ord($data[$nn + 2]);
+ $b3 = ($ii & 63);
+ $ii = ord($data[$nn + 3]);
+ $b4 = ($ii & 63);
+ $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
+ $ent = sprintf('%d;', $ii);
+ $escapedData .= $ent;
+ $nn += 3;
+ }
+ }
+
+ // when converting to latin-1, do not be so eager with using entities for characters 160-255
+ if ($conversion == 'UTF-8_ISO-8859-1') {
+ $escapedData = str_replace(array_slice($this->xml_iso88591_Entities['out'], 32), array_slice($this->xml_iso88591_Entities['in'], 32), $escapedData);
+ }
+ break;
+
+ /*
+ case 'CP1252_':
+ case 'CP1252_US-ASCII':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escapedData = str_replace($this->xml_iso88591_Entities']['in'], $this->xml_iso88591_Entities['out'], $escapedData);
+ $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData);
+ break;
+ case 'CP1252_UTF-8':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them)
+ $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData);
+ $escapedData = utf8_encode($escapedData);
+ break;
+ case 'CP1252_ISO-8859-1':
+ $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ // we might as well replace all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities...
+ $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData);
+ break;
+ */
+
+ default:
+ $escapedData = '';
+ error_log('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
+ }
+
+ return $escapedData;
+ }
+
+ /**
+ * Checks if a given charset encoding is present in a list of encodings or
+ * if it is a valid subset of any encoding in the list.
+ *
+ * @param string $encoding charset to be tested
+ * @param string|array $validList comma separated list of valid charsets (or array of charsets)
+ *
+ * @return bool
+ */
+ public function isValidCharset($encoding, $validList)
+ {
+ if (is_string($validList)) {
+ $validList = explode(',', $validList);
+ }
+ if (@in_array(strtoupper($encoding), $validList)) {
+ return true;
+ } else {
+ if (array_key_exists($encoding, $this->charset_supersets)) {
+ foreach ($validList as $allowed) {
+ if (in_array($allowed, $this->charset_supersets[$encoding])) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * Used only for backwards compatibility
+ * @deprecated
+ *
+ * @param string $charset
+ *
+ * @return array
+ *
+ * @throws \Exception for unknown/unsupported charsets
+ */
+ public function getEntities($charset)
+ {
+ switch ($charset)
+ {
+ case 'iso88591':
+ return $this->xml_iso88591_Entities;
+ default:
+ throw new \Exception('Unsupported charset: ' . $charset);
+ }
+ }
+
+}
diff --git a/php/phpxmlrpc/src/Helper/Date.php b/php/phpxmlrpc/src/Helper/Date.php
new file mode 100644
index 0000000..f97f52c
--- /dev/null
+++ b/php/phpxmlrpc/src/Helper/Date.php
@@ -0,0 +1,63 @@
+ 0) {
+ $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize);
+
+ // just in case we got a broken connection
+ if ($chunkEnd == false) {
+ $chunk = substr($buffer, $chunkStart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ $length += strlen($chunk);
+ break;
+ }
+
+ // read chunk-data and crlf
+ $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ // length := length + chunk-size
+ $length += strlen($chunk);
+ // read chunk-size and crlf
+ $chunkStart = $chunkEnd + 2;
+
+ $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2;
+ if ($chunkEnd == false) {
+ break; //just in case we got a broken connection
+ }
+ $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
+ $chunkSize = hexdec(trim($temp));
+ $chunkStart = $chunkEnd;
+ }
+
+ return $new;
+ }
+
+ /**
+ * Parses HTTP an http response headers and separates them from the body.
+ *
+ * @param string $data the http response,headers and body. It will be stripped of headers
+ * @param bool $headersProcessed when true, we assume that response inflating and dechunking has been already carried out
+ *
+ * @return array with keys 'headers' and 'cookies'
+ * @throws \Exception
+ */
+ public function parseResponseHeaders(&$data, $headersProcessed = false, $debug=0)
+ {
+ $httpResponse = array('raw_data' => $data, 'headers'=> array(), 'cookies' => array());
+
+ // Support "web-proxy-tunelling" connections for https through proxies
+ if (preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) {
+ // Look for CR/LF or simple LF as line separator,
+ // (even though it is not valid http)
+ $pos = strpos($data, "\r\n\r\n");
+ if ($pos || is_int($pos)) {
+ $bd = $pos + 4;
+ } else {
+ $pos = strpos($data, "\n\n");
+ if ($pos || is_int($pos)) {
+ $bd = $pos + 2;
+ } else {
+ // No separation between response headers and body: fault?
+ $bd = 0;
+ }
+ }
+ if ($bd) {
+ // this filters out all http headers from proxy.
+ // maybe we could take them into account, too?
+ $data = substr($data, $bd);
+ } else {
+ error_log('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
+ throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
+ }
+ }
+
+ // Strip HTTP 1.1 100 Continue header if present
+ while (preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) {
+ $pos = strpos($data, 'HTTP', 12);
+ // server sent a Continue header without any (valid) content following...
+ // give the client a chance to know it
+ if (!$pos && !is_int($pos)) {
+ // works fine in php 3, 4 and 5
+
+ break;
+ }
+ $data = substr($data, $pos);
+ }
+ if (!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) {
+ $errstr = substr($data, 0, strpos($data, "\n") - 1);
+ error_log('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
+ throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error']);
+ }
+
+ // be tolerant to usage of \n instead of \r\n to separate headers and data
+ // (even though it is not valid http)
+ $pos = strpos($data, "\r\n\r\n");
+ if ($pos || is_int($pos)) {
+ $bd = $pos + 4;
+ } else {
+ $pos = strpos($data, "\n\n");
+ if ($pos || is_int($pos)) {
+ $bd = $pos + 2;
+ } else {
+ // No separation between response headers and body: fault?
+ // we could take some action here instead of going on...
+ $bd = 0;
+ }
+ }
+ // be tolerant to line endings, and extra empty lines
+ $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
+ while (list(, $line) = @each($ar)) {
+ // take care of multi-line headers and cookies
+ $arr = explode(':', $line, 2);
+ if (count($arr) > 1) {
+ $headerName = strtolower(trim($arr[0]));
+ /// @todo some other headers (the ones that allow a CSV list of values)
+ /// do allow many values to be passed using multiple header lines.
+ /// We should add content to $xmlrpc->_xh['headers'][$headerName]
+ /// instead of replacing it for those...
+ if ($headerName == 'set-cookie' || $headerName == 'set-cookie2') {
+ if ($headerName == 'set-cookie2') {
+ // version 2 cookies:
+ // there could be many cookies on one line, comma separated
+ $cookies = explode(',', $arr[1]);
+ } else {
+ $cookies = array($arr[1]);
+ }
+ foreach ($cookies as $cookie) {
+ // glue together all received cookies, using a comma to separate them
+ // (same as php does with getallheaders())
+ if (isset($httpResponse['headers'][$headerName])) {
+ $httpResponse['headers'][$headerName] .= ', ' . trim($cookie);
+ } else {
+ $httpResponse['headers'][$headerName] = trim($cookie);
+ }
+ // parse cookie attributes, in case user wants to correctly honour them
+ // feature creep: only allow rfc-compliant cookie attributes?
+ // @todo support for server sending multiple time cookie with same name, but using different PATHs
+ $cookie = explode(';', $cookie);
+ foreach ($cookie as $pos => $val) {
+ $val = explode('=', $val, 2);
+ $tag = trim($val[0]);
+ $val = trim(@$val[1]);
+ /// @todo with version 1 cookies, we should strip leading and trailing " chars
+ if ($pos == 0) {
+ $cookiename = $tag;
+ $httpResponse['cookies'][$tag] = array();
+ $httpResponse['cookies'][$cookiename]['value'] = urldecode($val);
+ } else {
+ if ($tag != 'value') {
+ $httpResponse['cookies'][$cookiename][$tag] = $val;
+ }
+ }
+ }
+ }
+ } else {
+ $httpResponse['headers'][$headerName] = trim($arr[1]);
+ }
+ } elseif (isset($headerName)) {
+ /// @todo version1 cookies might span multiple lines, thus breaking the parsing above
+ $httpResponse['headers'][$headerName] .= ' ' . trim($line);
+ }
+ }
+
+ $data = substr($data, $bd);
+
+ if ($debug && count($httpResponse['headers'])) {
+ $msg = '';
+ foreach ($httpResponse['headers'] as $header => $value) {
+ $msg .= "HEADER: $header: $value\n";
+ }
+ foreach ($httpResponse['cookies'] as $header => $value) {
+ $msg .= "COOKIE: $header={$value['value']}\n";
+ }
+ Logger::instance()->debugMessage($msg);
+ }
+
+ // if CURL was used for the call, http headers have been processed,
+ // and dechunking + reinflating have been carried out
+ if (!$headersProcessed) {
+ // Decode chunked encoding sent by http 1.1 servers
+ if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') {
+ if (!$data = Http::decodeChunked($data)) {
+ error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
+ throw new \Exception(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail']);
+ }
+ }
+
+ // Decode gzip-compressed stuff
+ // code shamelessly inspired from nusoap library by Dietrich Ayala
+ if (isset($httpResponse['headers']['content-encoding'])) {
+ $httpResponse['headers']['content-encoding'] = str_replace('x-', '', $httpResponse['headers']['content-encoding']);
+ if ($httpResponse['headers']['content-encoding'] == 'deflate' || $httpResponse['headers']['content-encoding'] == 'gzip') {
+ // if decoding works, use it. else assume data wasn't gzencoded
+ if (function_exists('gzinflate')) {
+ if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
+ $data = $degzdata;
+ if ($debug) {
+ Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
+ }
+ } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
+ $data = $degzdata;
+ if ($debug) {
+ Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
+ }
+ } else {
+ error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
+ throw new \Exception(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail']);
+ }
+ } else {
+ error_log('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ throw new \Exception(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress']);
+ }
+ }
+ }
+ } // end of 'if needed, de-chunk, re-inflate response'
+
+ return $httpResponse;
+ }
+}
diff --git a/php/phpxmlrpc/src/Helper/Logger.php b/php/phpxmlrpc/src/Helper/Logger.php
new file mode 100644
index 0000000..77e0e14
--- /dev/null
+++ b/php/phpxmlrpc/src/Helper/Logger.php
@@ -0,0 +1,52 @@
+\n".htmlentities($message, $flags, $encoding)."\n";
+ } else {
+ print "