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