2 // by Edd Dumbill (C) 1999-2002
5 // Copyright (c) 1999,2000,2002 Edd Dumbill.
6 // All rights reserved.
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
15 // * Redistributions in binary form must reproduce the above
16 // copyright notice, this list of conditions and the following
17 // disclaimer in the documentation and/or other materials provided
18 // with the distribution.
20 // * Neither the name of the "XML-RPC for PHP" nor the names of its
21 // contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 // REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
35 // OF THE POSSIBILITY OF SUCH DAMAGE.
37 /******************************************************************************
41 * This file is only used to insure backwards compatibility
42 * with the API of the library <= rev. 3
44 * If it is included, the library will work without any further autoloading.
46 * NB: including this file will also alter the library configuration setting the
47 * expected charset encoding used by the app to ISO-8859-1. Please see the
48 * file api_changes_v4.md for how to change this if required.
49 *****************************************************************************/
51 include_once(__DIR__.'/../src/Client.php');
52 include_once(__DIR__.'/../src/Encoder.php');
53 include_once(__DIR__.'/../src/PhpXmlRpc.php');
54 include_once(__DIR__.'/../src/Request.php');
55 include_once(__DIR__.'/../src/Response.php');
56 include_once(__DIR__.'/../src/Value.php');
57 include_once(__DIR__.'/../src/Helper/Charset.php');
58 include_once(__DIR__.'/../src/Helper/Date.php');
59 include_once(__DIR__.'/../src/Helper/Http.php');
60 include_once(__DIR__.'/../src/Helper/Logger.php');
61 include_once(__DIR__.'/../src/Helper/XMLParser.php');
64 use PhpXmlRpc\Encoder;
65 use PhpXmlRpc\Request;
66 use PhpXmlRpc\Response;
68 use PhpXmlRpc\Helper\Charset;
69 use PhpXmlRpc\Helper\Date;
70 use PhpXmlRpc\Helper\Http;
71 use PhpXmlRpc\Helper\XMLParser;
73 /* Expose the global variables which used to be defined */
74 PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1'; // old default
75 PhpXmlRpc\PhpXmlRpc::exportGlobals();
77 /* some stuff deprecated enough that we do not want to put it in the new lib version */
80 $GLOBALS['xmlEntities'] = array(
88 // formulate backslashes for escaping regexp
89 // Not in use anymore since 2.0. Shall we remove it?
91 $GLOBALS['xmlrpc_backslash'] = chr(92).chr(92);
93 /* Expose with the old names the classes which have been namespaced */
96 * @todo reinstate access to method serializedata ?
98 class xmlrpcval extends Value
102 * @param xmlrpcval $o
105 public function serializeval($o)
107 // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
108 //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
114 return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
119 * @deprecated this code looks like it is very fragile and has not been fixed
120 * for a long long time. Shall we remove it for 2.0?
122 public function getval()
125 $b = reset($this->me);
127 // contributed by I Sofer, 2001-03-24
128 // add support for nested arrays to scalarval
129 // i've created a new method here, so as to
130 // preserve back compatibility
133 foreach($b as $id => $cont) {
134 $b[$id] = $cont->scalarval();
138 // add support for structures directly encoding php objects
140 $t = get_object_vars($b);
141 foreach($t as $id => $cont) {
142 $t[$id] = $cont->scalarval();
144 foreach($t as $id => $cont) {
152 /// reset functionality added by parent class: same as it would happen if no interface was declared
153 public function count()
158 /// reset functionality added by parent class: same as it would happen if no interface was declared
159 public function getIterator()
161 return new ArrayIterator($this);
166 * @todo reinstate access to method parseResponseHeaders ?
168 class xmlrpcmsg extends Request
172 class xmlrpcresp extends Response
177 * @todo reinstate access to methods sendPayloadHTTP10, sendPayloadHTTPS, sendPayloadCURL, _try_multicall ?
179 class xmlrpc_client extends Client
183 /* Expose as global functions the ones which are now class methods */
185 /// Wrong speling, but we are adamant on backwards compatibility!
186 function xmlrpc_encode_entitites($data, $srcEncoding='', $destEncoding='')
188 return Charset::instance()->encodeEntities($data, $srcEncoding, $destEncoding);
191 function iso8601_encode($timeT, $utc=0)
193 return Date::iso8601Encode($timeT, $utc);
196 function iso8601_decode($iDate, $utc=0)
198 return Date::iso8601Decode($iDate, $utc);
201 function decode_chunked($buffer)
203 return Http::decodeChunked($buffer);
206 function php_xmlrpc_decode($xmlrpcVal, $options=array())
208 $encoder = new Encoder();
209 return $encoder->decode($xmlrpcVal, $options);
212 function php_xmlrpc_encode($phpVal, $options=array())
214 $encoder = new Encoder();
215 return $encoder->encode($phpVal, $options);
218 function php_xmlrpc_decode_xml($xmlVal, $options=array())
220 $encoder = new Encoder();
221 return $encoder->decodeXml($xmlVal, $options);
224 function guess_encoding($httpHeader='', $xmlChunk='', $encodingPrefs=null)
226 return XMLParser::guessEncoding($httpHeader, $xmlChunk, $encodingPrefs);
229 function has_encoding($xmlChunk)
231 return XMLParser::hasEncoding($xmlChunk);
234 function is_valid_charset($encoding, $validList)
236 return Charset::instance()->isValidCharset($encoding, $validList);