1 | <?php |
||
2 | /** |
||
3 | * @author Gaetano Giunta |
||
4 | * @copyright (C) 2005-2023 G. Giunta |
||
5 | * @license code licensed under the BSD License: see file license.txt |
||
6 | * |
||
7 | * @todo switch params for http compression from 0,1,2 to values to be used directly |
||
8 | * @todo use ob_start to catch debug info and echo it AFTER method call results? |
||
9 | * @todo be smarter in creating client stub for proxy/auth cases: only set appropriate property of client obj |
||
10 | **/ |
||
11 | |||
12 | header('Content-Type: text/html; charset=utf-8'); |
||
13 | |||
14 | ?><!DOCTYPE html> |
||
15 | <html lang="en"> |
||
16 | <head> |
||
17 | <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico"> |
||
18 | <title><?php if (defined('DEFAULT_WSTYPE') && DEFAULT_WSTYPE == 1) echo 'JSON-RPC'; else echo 'XML-RPC'; ?> Debugger</title> |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
19 | <meta name="robots" content="index,nofollow"/> |
||
20 | <style type="text/css"> |
||
21 | <!-- |
||
22 | body { |
||
23 | border-top: 1px solid gray; |
||
24 | padding: 1em; |
||
25 | font-family: Verdana, Arial, Helvetica, sans-serif; |
||
26 | font-size: 8pt; |
||
27 | } |
||
28 | h3 { |
||
29 | font-size: 9.5pt; |
||
30 | } |
||
31 | h2 { |
||
32 | font-size: 12pt; |
||
33 | } |
||
34 | .dbginfo { |
||
35 | padding: 1em; |
||
36 | background-color: #EEEEEE; |
||
37 | border: 1px dashed silver; |
||
38 | font-family: monospace; |
||
39 | } |
||
40 | #response { |
||
41 | padding: 1em; |
||
42 | margin-top: 1em; |
||
43 | background-color: #DDDDDD; |
||
44 | border: 1px solid gray; |
||
45 | white-space: pre; |
||
46 | font-family: monospace; |
||
47 | } |
||
48 | table { |
||
49 | padding: 2px; |
||
50 | margin-top: 1em; |
||
51 | } |
||
52 | th { |
||
53 | background-color: navy; |
||
54 | color: white; |
||
55 | padding: 0.5em; |
||
56 | } |
||
57 | td { |
||
58 | padding: 0.5em; |
||
59 | font-family: monospace; |
||
60 | } |
||
61 | td form { |
||
62 | margin: 0; |
||
63 | } |
||
64 | .oddrow { |
||
65 | background-color: #EEEEEE; |
||
66 | } |
||
67 | .evidence { |
||
68 | color: blue; |
||
69 | } |
||
70 | #phpcode { |
||
71 | background-color: #EEEEEE; |
||
72 | padding: 1em; |
||
73 | margin-top: 1em; |
||
74 | } |
||
75 | --> |
||
76 | </style> |
||
77 | </head> |
||
78 | <body> |
||
79 | <?php |
||
80 | |||
81 | include __DIR__ . '/common.php'; |
||
82 | |||
83 | if ($action) { |
||
84 | |||
85 | // avoid php hanging when using the builtin webserver and sending requests to itself |
||
86 | $skip = false; |
||
87 | if (php_sapi_name() === 'cli-server' && ((int)getenv('PHP_CLI_SERVER_WORKERS') < 2)) { |
||
88 | $localHost = explode(':', $_SERVER['HTTP_HOST']); |
||
89 | /// @todo support also case where port is null (on either side), and when there is a Proxy in the parameters, |
||
90 | /// and that proxy is us |
||
91 | if ($localHost[0] == $host && (@$localHost[1] == $port)) { |
||
92 | $actionname = '[ERROR: can not make call to self when running php-cli webserver without setting PHP_CLI_SERVER_WORKERS]'; |
||
93 | $skip = true; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | if (!$skip) { |
||
98 | // make sure the script waits long enough for the call to complete... |
||
99 | if ($timeout) { |
||
100 | set_time_limit($timeout + 10); |
||
101 | } |
||
102 | |||
103 | if ($wstype == 1) { |
||
104 | $clientClass = '\PhpXmlRpc\JsonRpc\Client'; |
||
105 | $requestClass = '\PhpXmlRpc\JsonRpc\Request'; |
||
106 | $protoName = 'JSON-RPC'; |
||
107 | } else { |
||
108 | $clientClass = '\PhpXmlRpc\Client'; |
||
109 | $requestClass = '\PhpXmlRpc\Request'; |
||
110 | $protoName = 'XML-RPC'; |
||
111 | } |
||
112 | |||
113 | if ($port != "") { |
||
114 | $client = new $clientClass($path, $host, $port); |
||
115 | $server = "$host:$port$path"; |
||
116 | } else { |
||
117 | $client = new $clientClass($path, $host); |
||
118 | $server = "$host$path"; |
||
119 | } |
||
120 | if ($protocol == 2 || $protocol == 3) { |
||
121 | $server = 'https://' . $server; |
||
122 | } else { |
||
123 | $server = 'http://' . $server; |
||
124 | } |
||
125 | if ($proxy != '') { |
||
126 | $pproxy = explode(':', $proxy); |
||
127 | if (count($pproxy) > 1) { |
||
128 | $pport = $pproxy[1]; |
||
129 | } else { |
||
130 | $pport = 8080; |
||
131 | } |
||
132 | $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd); |
||
133 | } |
||
134 | |||
135 | if ($protocol == 2 || $protocol == 3) { |
||
136 | $client->setOption(\PhpXmlRpc\Client::OPT_VERIFY_PEER, $verifypeer); |
||
137 | $client->setOption(\PhpXmlRpc\Client::OPT_VERIFY_HOST, $verifyhost); |
||
138 | if ($cainfo) { |
||
139 | $client->setCaCertificate($cainfo); |
||
140 | } |
||
141 | if ($protocol == 3) { |
||
142 | $httpprotocol = 'h2'; |
||
143 | } else { |
||
144 | $httpprotocol = 'https'; |
||
145 | } |
||
146 | } elseif ($protocol == 4) { |
||
147 | $httpprotocol = 'h2c'; |
||
148 | } elseif ($protocol == 1) { |
||
149 | $httpprotocol = 'http11'; |
||
150 | } else { |
||
151 | $httpprotocol = 'http'; |
||
152 | } |
||
153 | |||
154 | if ($username) { |
||
155 | $client->setCredentials($username, $password, $authtype); |
||
156 | } |
||
157 | |||
158 | $client->setDebug($debug); |
||
159 | |||
160 | switch ($requestcompression) { |
||
161 | case 0: |
||
162 | $client->setOption(\PhpXmlRpc\Client::OPT_REQUEST_COMPRESSION, ''); |
||
163 | break; |
||
164 | case 1: |
||
165 | $client->setOption(\PhpXmlRpc\Client::OPT_REQUEST_COMPRESSION, 'gzip'); |
||
166 | break; |
||
167 | case 2: |
||
168 | $client->setOption(\PhpXmlRpc\Client::OPT_REQUEST_COMPRESSION, 'deflate'); |
||
169 | break; |
||
170 | } |
||
171 | |||
172 | switch ($responsecompression) { |
||
173 | case 0: |
||
174 | $client->setOption(\PhpXmlRpc\Client::OPT_ACCEPTED_COMPRESSION, ''); |
||
175 | break; |
||
176 | case 1: |
||
177 | $client->setOption(\PhpXmlRpc\Client::OPT_ACCEPTED_COMPRESSION, array('gzip')); |
||
178 | break; |
||
179 | case 2: |
||
180 | $client->setOption(\PhpXmlRpc\Client::OPT_ACCEPTED_COMPRESSION, ('deflate')); |
||
181 | break; |
||
182 | case 3: |
||
183 | $client->setOption(\PhpXmlRpc\Client::OPT_ACCEPTED_COMPRESSION, array('gzip', 'deflate')); |
||
184 | break; |
||
185 | } |
||
186 | |||
187 | $cookies = explode(',', $clientcookies); |
||
188 | foreach ($cookies as $cookie) { |
||
189 | if (strpos($cookie, '=')) { |
||
190 | $cookie = explode('=', $cookie); |
||
191 | $client->setCookie(trim($cookie[0]), trim(@$cookie[1])); |
||
192 | } |
||
193 | } |
||
194 | |||
195 | $msg = array(); |
||
196 | switch ($action) { |
||
197 | // fall thru intentionally |
||
198 | case 'describe': |
||
199 | case 'wrap': |
||
200 | $msg[0] = new $requestClass('system.methodHelp', array(), $id); |
||
201 | $msg[0]->addparam(new PhpXmlRpc\Value($method)); |
||
202 | $msg[1] = new $requestClass('system.methodSignature', array(), (int)$id + 1); |
||
203 | $msg[1]->addparam(new PhpXmlRpc\Value($method)); |
||
204 | $actionname = 'Description of method "' . $method . '"'; |
||
205 | break; |
||
206 | case 'list': |
||
207 | $msg[0] = new $requestClass('system.listMethods', array(), $id); |
||
208 | $actionname = 'List of available methods'; |
||
209 | break; |
||
210 | case 'execute': |
||
211 | if (!payload_is_safe($payload)) { |
||
212 | die("Tsk tsk tsk, please stop it or I will have to call in the cops!"); |
||
213 | } |
||
214 | $msg[0] = new $requestClass($method, array(), $id); |
||
215 | // hack! build payload by hand |
||
216 | if ($wstype == 1) { |
||
217 | $payload = "{\n" . |
||
218 | '"method": "' . $method . "\",\n\"params\": [" . |
||
219 | $payload . |
||
220 | "\n],\n\"id\": "; |
||
221 | // fix: if user gave an empty string, use NULL, or we'll break json syntax |
||
222 | if ($id == "") { |
||
223 | $payload .= "null\n}"; |
||
224 | } else { |
||
225 | if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null') { |
||
226 | $payload .= "$id\n}"; |
||
227 | } else { |
||
228 | $payload .= "\"$id\"\n}"; |
||
229 | } |
||
230 | } |
||
231 | $msg[0]->setPayload($payload); |
||
232 | } else { |
||
233 | $msg[0]->setPayload( |
||
234 | $msg[0]->xml_header($inputcharset) . |
||
235 | '<methodName>' . $method . "</methodName>\n<params>" . |
||
236 | $payload . |
||
237 | "</params>\n" . $msg[0]->xml_footer() |
||
238 | ); |
||
239 | } |
||
240 | $actionname = 'Execution of method ' . $method; |
||
241 | break; |
||
242 | default: // give a warning |
||
243 | $actionname = '[ERROR: unknown action] "' . $action . '"'; |
||
244 | } |
||
245 | } |
||
246 | |||
247 | // Before calling execute, echo out brief description of action taken + date and time ??? |
||
248 | // this gives good user feedback for long-running methods... |
||
249 | echo '<h2>' . htmlspecialchars($actionname, ENT_COMPAT, $inputcharset) . ' on server ' . htmlspecialchars($server, ENT_COMPAT, $inputcharset) . " ...</h2>\n"; |
||
250 | flush(); |
||
251 | |||
252 | $response = null; |
||
253 | // execute method(s) |
||
254 | if ($debug) { |
||
255 | echo '<div class="dbginfo"><h2>Debug info:</h2>'; |
||
256 | } /// @todo use ob_start instead |
||
257 | $resp = array(); |
||
258 | $time = microtime(true); |
||
259 | foreach ($msg as $message) { |
||
260 | $response = $client->send($message, $timeout, $httpprotocol); |
||
261 | $resp[] = $response; |
||
262 | if (!$response || $response->faultCode()) { |
||
263 | break; |
||
264 | } |
||
265 | } |
||
266 | $time = microtime(true) - $time; |
||
267 | if ($debug) { |
||
268 | echo "</div>\n"; |
||
269 | } |
||
270 | |||
271 | if ($response) { |
||
272 | if ($response->faultCode()) { |
||
273 | // call failed! echo out error msg! |
||
274 | //echo '<h2>'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'</h2>'; |
||
275 | echo "<h3>$protoName call FAILED!</h3>\n"; |
||
276 | echo "<p>Fault code: [" . htmlspecialchars($response->faultCode(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . |
||
277 | "] Reason: '" . htmlspecialchars($response->faultString(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "'</p>\n"; |
||
278 | echo(date("d/M/Y:H:i:s\n")); |
||
279 | } else { |
||
280 | // call succeeded: parse results |
||
281 | //echo '<h2>'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'</h2>'; |
||
282 | printf("<h3>%s call(s) OK (%.2f secs.)</h3>\n", $protoName, $time); |
||
283 | echo(date("d/M/Y:H:i:s\n")); |
||
284 | |||
285 | switch ($action) { |
||
286 | case 'list': |
||
287 | |||
288 | $v = $response->value(); |
||
289 | if ($v->kindOf() == "array") { |
||
290 | $max = $v->count(); |
||
291 | echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; |
||
292 | echo "<thead>\n<tr><th>Method ($max)</th><th>Description</th></tr>\n</thead>\n<tbody>\n"; |
||
293 | foreach($v as $i => $rec) { |
||
294 | if ($i % 2) { |
||
295 | $class = ' class="oddrow"'; |
||
296 | } else { |
||
297 | $class = ' class="evenrow"'; |
||
298 | } |
||
299 | echo("<tr><td$class>" . htmlspecialchars($rec->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "</td><td$class><form action=\"controller.php\" method=\"get\" target=\"frmcontroller\">" . |
||
300 | "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" . |
||
301 | "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" . |
||
302 | "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" . |
||
303 | "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" . |
||
304 | "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" . |
||
305 | "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" . |
||
306 | "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" . |
||
307 | "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" . |
||
308 | "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" . |
||
309 | "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" . |
||
310 | "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" . |
||
311 | "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" . |
||
312 | "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" . |
||
313 | "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" . |
||
314 | "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" . |
||
315 | "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" . |
||
316 | "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" . |
||
317 | "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" . |
||
318 | "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" . |
||
319 | "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($rec->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "\" />" . |
||
320 | "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" . |
||
321 | "<input type=\"hidden\" name=\"action\" value=\"describe\" />" . |
||
322 | "<input type=\"hidden\" name=\"run\" value=\"now\" />" . |
||
323 | "<input type=\"submit\" value=\"Describe\" /></form></td>"); |
||
324 | //echo("</tr>\n"); |
||
325 | |||
326 | // generate the skeleton for method payload per possible tests |
||
327 | //$methodpayload="<methodCall>\n<methodName>".$rec->scalarval()."</methodName>\n<params>\n<param><value></value></param>\n</params>\n</methodCall>"; |
||
328 | |||
329 | /*echo ("<form action=\"{$_SERVER['PHP_SELF']}\" method=\"get\"><td>". |
||
330 | "<input type=\"hidden\" name=\"host\" value=\"$host\" />". |
||
331 | "<input type=\"hidden\" name=\"port\" value=\"$port\" />". |
||
332 | "<input type=\"hidden\" name=\"path\" value=\"$path\" />". |
||
333 | "<input type=\"hidden\" name=\"method\" value=\"".$rec->scalarval()."\" />". |
||
334 | "<input type=\"hidden\" name=\"methodpayload\" value=\"$payload\" />". |
||
335 | "<input type=\"hidden\" name=\"action\" value=\"execute\" />". |
||
336 | "<input type=\"submit\" value=\"Test\" /></td></form>");*/ |
||
337 | echo("</tr>\n"); |
||
338 | } |
||
339 | echo "</tbody>\n</table>"; |
||
340 | } |
||
341 | break; |
||
342 | |||
343 | case 'describe': |
||
344 | |||
345 | $r1 = $resp[0]->value(); |
||
346 | $r2 = $resp[1]->value(); |
||
347 | |||
348 | echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; |
||
349 | echo "<thead>\n<tr><th>Method</th><th>" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "</th><th> </th><th> </th></tr>\n</thead>\n<tbody>\n"; |
||
350 | $desc = htmlspecialchars($r1->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding); |
||
351 | if ($desc == "") { |
||
352 | $desc = "-"; |
||
353 | } |
||
354 | echo "<tr><td class=\"evenrow\">Description</td><td colspan=\"3\" class=\"evenrow\">$desc</td></tr>\n"; |
||
355 | |||
356 | if ($r2->kindOf() != "array") { |
||
357 | echo "<tr><td class=\"oddrow\">Signature</td><td class=\"oddrow\">Unknown</td><td class=\"oddrow\"> </td></tr>\n"; |
||
358 | } else { |
||
359 | foreach($r2 as $i => $x) { |
||
360 | $payload = ""; |
||
361 | $alt_payload = ""; |
||
362 | if ($i + 1 % 2) { |
||
363 | $class = ' class="oddrow"'; |
||
364 | } else { |
||
365 | $class = ' class="evenrow"'; |
||
366 | } |
||
367 | echo "<tr><td$class>Signature " . ($i + 1) . "</td><td$class>"; |
||
368 | if ($x->kindOf() == "array") { |
||
369 | $ret = $x[0]; |
||
370 | echo "<code>OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "<br />IN: ("; |
||
371 | if ($x->count() > 1) { |
||
372 | foreach($x as $k => $y) { |
||
373 | if ($k == 0) continue; |
||
374 | echo htmlspecialchars($y->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding); |
||
375 | if ($wstype == 1) { |
||
376 | switch($y->scalarval()) { |
||
377 | case 'string': |
||
378 | case 'dateTime.iso8601': |
||
379 | case 'base64': |
||
380 | $payload .= '""'; |
||
381 | break; |
||
382 | case 'i4': |
||
383 | case 'i8': |
||
384 | case 'int': |
||
385 | $payload .= '0'; |
||
386 | break; |
||
387 | case 'double': |
||
388 | $payload .= '0.0'; |
||
389 | break; |
||
390 | case 'bool': |
||
391 | case 'boolean': |
||
392 | $payload .= 'true'; |
||
393 | break; |
||
394 | case 'null': |
||
395 | $payload .= 'null'; |
||
396 | break; |
||
397 | case 'array': |
||
398 | $payload .= '[]'; |
||
399 | break; |
||
400 | case 'struct': |
||
401 | $payload .= '{}'; |
||
402 | break; |
||
403 | default: |
||
404 | break; |
||
405 | } |
||
406 | } else { |
||
407 | $type = $y->scalarval(); |
||
408 | $payload .= '<param><value>'; |
||
409 | switch($type) { |
||
410 | case 'undefined': |
||
411 | break; |
||
412 | case 'null'; |
||
413 | $type = 'nil'; |
||
414 | // fall thru intentionally |
||
415 | default: |
||
416 | $payload .= '<' . |
||
417 | htmlspecialchars($type, ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . |
||
418 | '></' . htmlspecialchars($type, ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . |
||
419 | '>'; |
||
420 | } |
||
421 | $payload .= "</value></param>\n"; |
||
422 | } |
||
423 | $alt_payload .= $y->scalarval(); |
||
424 | if ($k < $x->count() - 1) { |
||
425 | $alt_payload .= ';'; |
||
426 | if ($wstype == 1) { |
||
427 | $payload .= ', '; |
||
428 | } |
||
429 | echo ", "; |
||
430 | } |
||
431 | } |
||
432 | } |
||
433 | echo ")</code>"; |
||
434 | } else { |
||
435 | echo 'Unknown'; |
||
436 | } |
||
437 | echo '</td>'; |
||
438 | // button to test this method |
||
439 | //$payload="<methodCall>\n<methodName>$method</methodName>\n<params>\n$payload</params>\n</methodCall>"; |
||
440 | echo "<td$class><form action=\"controller.php\" target=\"frmcontroller\" method=\"get\">" . |
||
441 | "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" . |
||
442 | "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" . |
||
443 | "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" . |
||
444 | "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" . |
||
445 | "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" . |
||
446 | "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" . |
||
447 | "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" . |
||
448 | "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" . |
||
449 | "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" . |
||
450 | "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" . |
||
451 | "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" . |
||
452 | "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" . |
||
453 | "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" . |
||
454 | "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" . |
||
455 | "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" . |
||
456 | "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" . |
||
457 | "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" . |
||
458 | "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" . |
||
459 | "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" . |
||
460 | "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "\" />" . |
||
461 | "<input type=\"hidden\" name=\"methodpayload\" value=\"" . htmlspecialchars($payload, ENT_COMPAT, $inputcharset) . "\" />" . |
||
462 | "<input type=\"hidden\" name=\"altmethodpayload\" value=\"" . htmlspecialchars($alt_payload, ENT_COMPAT, $inputcharset) . "\" />" . |
||
463 | "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" . |
||
464 | "<input type=\"hidden\" name=\"action\" value=\"execute\" />"; |
||
465 | //if ($wstype != 1) { |
||
466 | echo "<input type=\"submit\" value=\"Load method synopsis\" />"; |
||
467 | //} |
||
468 | echo "</form></td>\n"; |
||
469 | |||
470 | echo "<td$class><form action=\"controller.php\" target=\"frmcontroller\" method=\"get\">" . |
||
471 | "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" . |
||
472 | "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" . |
||
473 | "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" . |
||
474 | "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" . |
||
475 | "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" . |
||
476 | "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" . |
||
477 | "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" . |
||
478 | "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" . |
||
479 | "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" . |
||
480 | "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" . |
||
481 | "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" . |
||
482 | "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" . |
||
483 | "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" . |
||
484 | "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" . |
||
485 | "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" . |
||
486 | "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" . |
||
487 | "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" . |
||
488 | "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" . |
||
489 | "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" . |
||
490 | "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "\" />" . |
||
491 | "<input type=\"hidden\" name=\"methodsig\" value=\"" . $i . "\" />" . |
||
492 | "<input type=\"hidden\" name=\"methodpayload\" value=\"" . htmlspecialchars($payload, ENT_COMPAT, $inputcharset) . "\" />" . |
||
493 | "<input type=\"hidden\" name=\"altmethodpayload\" value=\"" . htmlspecialchars($alt_payload, ENT_COMPAT, $inputcharset) . "\" />" . |
||
494 | "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" . |
||
495 | "<input type=\"hidden\" name=\"action\" value=\"wrap\" />" . |
||
496 | "<input type=\"hidden\" name=\"run\" value=\"now\" />" . |
||
497 | "<input type=\"submit\" value=\"Generate method call stub code\" />"; |
||
498 | echo "</form></td></tr>\n"; |
||
499 | } |
||
500 | } |
||
501 | echo "</tbody>\n</table>"; |
||
502 | |||
503 | break; |
||
504 | |||
505 | case 'wrap': |
||
506 | $r1 = $resp[0]->value(); |
||
507 | $r2 = $resp[1]->value(); |
||
508 | if ($r2->kindOf() != "array" || $r2->count() <= $methodsig) { |
||
509 | echo "Error: signature unknown\n"; |
||
510 | } else { |
||
511 | $mdesc = $r1->scalarval(); |
||
512 | $encoder = new PhpXmlRpc\Encoder(); |
||
513 | $msig = $encoder->decode($r2); |
||
514 | $msig = $msig[$methodsig]; |
||
515 | $proto = ($protocol == 1) ? 'http11' : ( $protocol == 2 ? 'https' : ( $protocol == 3 ? 'h2' : ( $protocol == 4 ? 'h2c' : '' ) ) ); |
||
516 | if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression && |
||
517 | $clientcookies == '') { |
||
518 | $opts = 1; // simple client copy in stub code |
||
519 | } else { |
||
520 | $opts = 0; // complete client copy in stub code |
||
521 | } |
||
522 | if ($wstype == 1) { |
||
523 | $prefix = 'jsonrpc'; |
||
524 | } else { |
||
525 | $prefix = 'xmlrpc'; |
||
526 | } |
||
527 | if ($wstype == 1) { |
||
528 | $wrapper = new PhpXmlRpc\JsonRpc\Wrapper(); |
||
0 ignored issues
–
show
The type
PhpXmlRpc\JsonRpc\Wrapper was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
529 | } else { |
||
530 | $wrapper = new PhpXmlRpc\Wrapper(); |
||
531 | } |
||
532 | $code = $wrapper->buildWrapMethodSource( |
||
533 | $client, |
||
534 | $method, |
||
535 | array('timeout' => $timeout, 'protocol' => $proto, 'simple_client_copy' => $opts, 'prefix' => $prefix, 'throw_on_fault' => true), |
||
536 | str_replace('.', '_', $prefix . '_' . $method), $msig, $mdesc |
||
537 | ); |
||
538 | //if ($code) |
||
539 | //{ |
||
540 | echo "<div id=\"phpcode\">\n"; |
||
541 | highlight_string("<?php\n" . $code['docstring'] . $code['source']); |
||
542 | echo "\n</div>"; |
||
543 | //} |
||
544 | //else |
||
545 | //{ |
||
546 | // echo 'Error while building php code stub...'; |
||
547 | } |
||
548 | |||
549 | break; |
||
550 | |||
551 | case 'execute': |
||
552 | echo '<div id="response"><h2>Response:</h2>' . htmlspecialchars($response->serialize()) . '</div>'; |
||
553 | break; |
||
554 | |||
555 | default: // give a warning |
||
556 | } |
||
557 | } // if !$response->faultCode() |
||
558 | } // if $response |
||
559 | } else { |
||
560 | // no action taken yet: give some instructions on debugger usage |
||
561 | ?> |
||
562 | |||
563 | <h3>Instructions on usage of the debugger</h3> |
||
564 | <ol> |
||
565 | <li>Run a 'list available methods' action against desired server</li> |
||
566 | <li>If list of methods appears, click on 'describe method' for desired method</li> |
||
567 | <li>To run method: click on 'load method synopsis' for desired method. This will load a skeleton for method call |
||
568 | parameters in the form above. Complete all xml-rpc values with appropriate data and click 'Execute' |
||
569 | </li> |
||
570 | </ol> |
||
571 | <?php |
||
572 | if (!extension_loaded('curl')) { |
||
573 | echo "<p class=\"evidence\">You will need to enable the cURL extension to use the HTTPS, HTTP 1.1 and HTTP/2 transports</p>\n"; |
||
574 | } |
||
575 | ?> |
||
576 | |||
577 | <h3>Example</h3> |
||
578 | <p> |
||
579 | Server Address: gggeek.altervista.org<br/> |
||
580 | Path: /sw/xmlrpc/demo/server/server.php |
||
581 | </p> |
||
582 | |||
583 | <h3>Notice</h3> |
||
584 | <p>all usernames and passwords entered on the above form will be written to the web server logs of this server. Use |
||
585 | with care.</p> |
||
586 | |||
587 | <h3>Changelog</h3> |
||
588 | <ul> |
||
589 | <li>2023-02-11: display in the top row the version of the libraries in use; made the generated code throw instead |
||
590 | of returning a Response object on error; fixes for the json-rpc debugger</li> |
||
591 | <li>2022-12-18: fix XSS vulnerability in the debugger; load jsxmlrpc from CDN; minor improvements</li> |
||
592 | <li>2022-11-28: allow to use http/2 protocol; two security issues fixed in the underlying library</li> |
||
593 | <li>2020-12-11: fix problems with running the debugger on php 8</li> |
||
594 | <li>2015-05-30: fix problems with generating method payloads for NIL and Undefined parameters</li> |
||
595 | <li>2015-04-19: fix problems with LATIN-1 characters in payload</li> |
||
596 | <li>2007-02-20: add visual editor for method payload; allow strings, bools as jsonrpc msg id</li> |
||
597 | <li>2006-06-26: support building php code stub for calling remote methods</li> |
||
598 | <li>2006-05-25: better support for long running queries; check for no-curl installs</li> |
||
599 | <li>2006-05-02: added support for JSON-RPC. Note that many interesting json-rpc features are not implemented |
||
600 | yet, such as notifications or multicall. |
||
601 | </li> |
||
602 | <li>2006-04-22: added option for setting custom CA certs to verify peer with in SSLmode</li> |
||
603 | <li>2006-03-05: added option for setting Basic/Digest/NTLM auth type</li> |
||
604 | <li>2006-01-18: added option echoing to screen xml-rpc request before sending it ('More' debug)</li> |
||
605 | <li>2005-10-01: added option for setting cookies to be sent to server</li> |
||
606 | <li>2005-08-07: added switches for compression of requests and responses and http 1.1</li> |
||
607 | <li>2005-06-27: fixed possible security breach in parsing malformed xml</li> |
||
608 | <li>2005-06-24: fixed error with calling methods having parameters...</li> |
||
609 | </ul> |
||
610 | <?php |
||
611 | |||
612 | } |
||
613 | ?> |
||
614 | </body> |
||
615 | </html> |
||
616 |