1 | <?php |
||
2 | // by Edd Dumbill (C) 1999-2002 |
||
3 | // <[email protected]> |
||
4 | |||
5 | // Copyright (c) 1999,2000,2002 Edd Dumbill. |
||
6 | // All rights reserved. |
||
7 | // |
||
8 | // Redistribution and use in source and binary forms, with or without |
||
9 | // modification, are permitted provided that the following conditions |
||
10 | // are met: |
||
11 | // |
||
12 | // * Redistributions of source code must retain the above copyright |
||
13 | // notice, this list of conditions and the following disclaimer. |
||
14 | // |
||
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. |
||
19 | // |
||
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. |
||
23 | // |
||
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. |
||
36 | |||
37 | /****************************************************************************** |
||
38 | * |
||
39 | * *** DEPRECATED *** |
||
40 | * |
||
41 | * This file is only used to insure backwards compatibility |
||
42 | * with the API of the library <= rev. 3 |
||
43 | * |
||
44 | * If it is included, the library will work without any further autoloading. |
||
45 | * |
||
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 | *****************************************************************************/ |
||
50 | |||
51 | // the list is sorted more-or-less in dependency order |
||
52 | include_once(__DIR__.'/../src/Exception.php'); |
||
53 | include_once(__DIR__.'/../src/Exception/FaultResponseException.php'); |
||
54 | include_once(__DIR__.'/../src/Exception/ParsingException.php'); |
||
55 | include_once(__DIR__.'/../src/Exception/XmlException.php'); |
||
56 | include_once(__DIR__.'/../src/Exception/XmlRpcException.php'); |
||
57 | include_once(__DIR__.'/../src/Exception/TransportException.php'); |
||
58 | include_once(__DIR__.'/../src/Exception/HttpException.php'); |
||
59 | include_once(__DIR__.'/../src/Exception/ServerException.php'); |
||
60 | include_once(__DIR__.'/../src/Exception/NoSuchMethodException.php'); |
||
61 | include_once(__DIR__.'/../src/Exception/StateErrorException.php'); |
||
62 | include_once(__DIR__.'/../src/Exception/TypeErrorException.php'); |
||
63 | include_once(__DIR__.'/../src/Exception/ValueErrorException.php'); |
||
64 | include_once(__DIR__.'/../src/PhpXmlRpc.php'); |
||
65 | include_once(__DIR__.'/../src/Traits/CharsetEncoderAware.php'); |
||
66 | include_once(__DIR__.'/../src/Traits/LoggerAware.php'); |
||
67 | include_once(__DIR__.'/../src/Traits/DeprecationLogger.php'); |
||
68 | include_once(__DIR__.'/../src/Traits/ParserAware.php'); |
||
69 | include_once(__DIR__.'/../src/Traits/PayloadBearer.php'); |
||
70 | include_once(__DIR__.'/../src/Helper/Charset.php'); |
||
71 | include_once(__DIR__.'/../src/Helper/Date.php'); |
||
72 | include_once(__DIR__.'/../src/Helper/Http.php'); |
||
73 | include_once(__DIR__.'/../src/Helper/Interop.php'); |
||
74 | include_once(__DIR__.'/../src/Helper/Logger.php'); |
||
75 | include_once(__DIR__.'/../src/Helper/XMLParser.php'); |
||
76 | include_once(__DIR__.'/../src/Value.php'); |
||
77 | include_once(__DIR__.'/../src/Request.php'); |
||
78 | include_once(__DIR__.'/../src/Response.php'); |
||
79 | include_once(__DIR__.'/../src/Client.php'); |
||
80 | include_once(__DIR__.'/../src/Encoder.php'); |
||
81 | |||
82 | use PhpXmlRpc\Client; |
||
83 | use PhpXmlRpc\Encoder; |
||
84 | use PhpXmlRpc\Request; |
||
85 | use PhpXmlRpc\Response; |
||
86 | use PhpXmlRpc\Value; |
||
87 | use PhpXmlRpc\Helper\Charset; |
||
88 | use PhpXmlRpc\Helper\Date; |
||
89 | use PhpXmlRpc\Helper\Http; |
||
90 | use PhpXmlRpc\Helper\XMLParser; |
||
91 | |||
92 | /* Expose the global variables which used to be defined */ |
||
93 | PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1'; // old default |
||
94 | PhpXmlRpc\PhpXmlRpc::exportGlobals(); |
||
95 | |||
96 | /* some stuff deprecated enough that we do not want to put it in the new lib version */ |
||
97 | |||
98 | /// @deprecated |
||
99 | $GLOBALS['xmlEntities'] = array( |
||
100 | 'amp' => '&', |
||
101 | 'quot' => '"', |
||
102 | 'lt' => '<', |
||
103 | 'gt' => '>', |
||
104 | 'apos' => "'" |
||
105 | ); |
||
106 | |||
107 | // formulate backslashes for escaping regexp |
||
108 | // Not in use anymore since 2.0. Shall we remove it? |
||
109 | /// @deprecated |
||
110 | $GLOBALS['xmlrpc_backslash'] = chr(92).chr(92); |
||
111 | |||
112 | /* Expose with the old names the classes which have been namespaced */ |
||
113 | |||
114 | /** |
||
115 | * @todo reinstate access to method serializeData? |
||
116 | */ |
||
117 | class xmlrpcval extends Value |
||
118 | { |
||
119 | /** |
||
120 | * @deprecated |
||
121 | * @param xmlrpcval $o |
||
122 | * @return string |
||
123 | */ |
||
124 | public function serializeval($o) |
||
125 | { |
||
126 | // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... |
||
127 | //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) |
||
128 | //{ |
||
129 | $ar = $o->me; |
||
130 | $val = reset($ar); |
||
131 | $typ = key($ar); |
||
132 | |||
133 | return '<value>' . $this->serializeData($typ, $val) . "</value>\n"; |
||
134 | //} |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @deprecated this code looks like it is very fragile and has not been fixed for a long long time. |
||
139 | * Shall we remove it for 2.0? |
||
140 | */ |
||
141 | public function getval() |
||
142 | { |
||
143 | // UNSTABLE |
||
144 | $b = reset($this->me); |
||
145 | $a = key($this->me); |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
146 | // contributed by I Sofer, 2001-03-24 |
||
147 | // add support for nested arrays to scalarval |
||
148 | // i've created a new method here, so as to |
||
149 | // preserve back compatibility |
||
150 | |||
151 | if (is_array($b)) { |
||
152 | foreach($b as $id => $cont) { |
||
153 | $b[$id] = $cont->scalarVal(); |
||
154 | } |
||
155 | } |
||
156 | |||
157 | // add support for structures directly encoding php objects |
||
158 | if (is_object($b)) { |
||
159 | $t = get_object_vars($b); |
||
160 | foreach($t as $id => $cont) { |
||
161 | $t[$id] = $cont->scalarVal(); |
||
162 | } |
||
163 | foreach($t as $id => $cont) { |
||
164 | @$b->$id = $cont; |
||
165 | } |
||
166 | } |
||
167 | // end contrib |
||
168 | return $b; |
||
169 | } |
||
170 | |||
171 | /// reset functionality added by parent class: same as it would happen if no interface was declared |
||
172 | public function count() |
||
173 | { |
||
174 | return 1; |
||
175 | } |
||
176 | |||
177 | /// reset functionality added by parent class: same as it would happen if no interface was declared |
||
178 | public function getIterator() |
||
179 | { |
||
180 | return new ArrayIterator($this); |
||
181 | } |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * @todo reinstate access to method parseResponseHeaders? |
||
186 | */ |
||
187 | class xmlrpcmsg extends Request |
||
188 | { |
||
189 | } |
||
190 | |||
191 | class xmlrpcresp extends Response |
||
192 | { |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @todo reinstate access to methods sendPayloadHTTP10, sendPayloadHTTPS, sendPayloadCURL, _try_multicall? |
||
197 | */ |
||
198 | class xmlrpc_client extends Client |
||
199 | { |
||
200 | } |
||
201 | |||
202 | /* Expose as global functions the ones which are now class methods */ |
||
203 | |||
204 | /// Wrong speling, but we are adamant on backwards compatibility! |
||
205 | function xmlrpc_encode_entitites($data, $srcEncoding='', $destEncoding='') |
||
206 | { |
||
207 | return Charset::instance()->encodeEntities($data, $srcEncoding, $destEncoding); |
||
208 | } |
||
209 | |||
210 | function iso8601_encode($timeT, $utc=0) |
||
211 | { |
||
212 | return Date::iso8601Encode($timeT, $utc); |
||
213 | } |
||
214 | |||
215 | function iso8601_decode($iDate, $utc=0) |
||
216 | { |
||
217 | return Date::iso8601Decode($iDate, $utc); |
||
218 | } |
||
219 | |||
220 | function decode_chunked($buffer) |
||
221 | { |
||
222 | return Http::decodeChunked($buffer); |
||
223 | } |
||
224 | |||
225 | function php_xmlrpc_decode($xmlrpcVal, $options=array()) |
||
226 | { |
||
227 | $encoder = new Encoder(); |
||
228 | return $encoder->decode($xmlrpcVal, $options); |
||
229 | } |
||
230 | |||
231 | function php_xmlrpc_encode($phpVal, $options=array()) |
||
232 | { |
||
233 | $encoder = new Encoder(); |
||
234 | return $encoder->encode($phpVal, $options); |
||
235 | } |
||
236 | |||
237 | function php_xmlrpc_decode_xml($xmlVal, $options=array()) |
||
238 | { |
||
239 | $encoder = new Encoder(); |
||
240 | return $encoder->decodeXml($xmlVal, $options); |
||
241 | } |
||
242 | |||
243 | function guess_encoding($httpHeader='', $xmlChunk='', $encodingPrefs=null) |
||
244 | { |
||
245 | return XMLParser::guessEncoding($httpHeader, $xmlChunk, $encodingPrefs); |
||
246 | } |
||
247 | |||
248 | function has_encoding($xmlChunk) |
||
249 | { |
||
250 | return XMLParser::hasEncoding($xmlChunk); |
||
251 | } |
||
252 | |||
253 | function is_valid_charset($encoding, $validList) |
||
254 | { |
||
255 | return Charset::instance()->isValidCharset($encoding, $validList); |
||
256 | } |
||
257 |