3 * @author Gaetano Giunta
4 * @copyright (C) 2005-2015 G. Giunta
5 * @license code licensed under the BSD License: see file license.txt
7 * @todo add links to documentation from every option caption
8 * @todo switch params for http compression from 0,1,2 to values to be used directly
9 * @todo add a little bit more CSS formatting: we broke IE box model getting a width > 100%...
10 * @todo add support for more options, such as ntlm auth to proxy, or request charset encoding
11 * @todo parse content of payload textarea to be fed to visual editor
12 * @todo add http no-cache headers
15 include __DIR__ . '/common.php';
20 // relative path to the visual xmlrpc editing dialog
21 $editorpath = '../../phpjsrpc/debugger/';
22 $editorlibs = '../../phpjsrpc/lib/';
24 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
25 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
26 <html xmlns="http://www.w3.org/1999/xhtml">
28 <title>XMLRPC Debugger</title>
29 <meta name="robots" content="index,nofollow"/>
30 <script type="text/javascript" language="Javascript">
31 if (window.name != 'frmcontroller')
32 top.location.replace('index.php?run=' + escape(self.location));
34 <!-- xmlrpc/jsonrpc base library -->
35 <script type="text/javascript" src="<?php echo $editorlibs; ?>xmlrpc_lib.js"></script>
36 <script type="text/javascript" src="<?php echo $editorlibs; ?>jsonrpc_lib.js"></script>
37 <style type="text/css">
40 overflow: -moz-scrollbars-vertical;
45 background-color: #EEEEEE;
46 font-family: Verdana, Arial, Helvetica;
62 border: 1px solid gray;
74 font-family: Verdana, Arial, Helvetica;
84 <script language="JavaScript" type="text/javascript">
86 function verifyserver() {
87 if (document.frmaction.host.value == '') {
88 alert('Please insert a server name or address');
91 if (document.frmaction.path.value == '')
92 document.frmaction.path.value = '/';
94 for (counter = 0; counter < document.frmaction.action.length; counter++)
95 if (document.frmaction.action[counter].checked) {
96 action = document.frmaction.action[counter].value;
98 if (document.frmaction.method.value == '' && (action == 'execute' || action == 'wrap' || action == 'describe')) {
99 alert('Please insert a method name');
102 if (document.frmaction.authtype.value != '1' && document.frmaction.username.value == '') {
103 alert('No username for authenticating to server: authentication disabled');
108 function switchaction() {
109 // reset html layout depending on action to be taken
111 for (counter = 0; counter < document.frmaction.action.length; counter++)
112 if (document.frmaction.action[counter].checked) {
113 action = document.frmaction.action[counter].value;
115 if (action == 'execute') {
116 document.frmaction.methodpayload.disabled = false;
117 displaydialogeditorbtn(true);//if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
118 document.frmaction.method.disabled = false;
119 document.frmaction.methodpayload.rows = 10;
122 document.frmaction.methodpayload.rows = 1;
123 if (action == 'describe' || action == 'wrap') {
124 document.frmaction.methodpayload.disabled = true;
125 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = true;
126 document.frmaction.method.disabled = false;
130 document.frmaction.methodpayload.disabled = true;
131 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
132 document.frmaction.method.disabled = true;
137 function switchssl() {
138 if (document.frmaction.protocol.value != '2') {
139 document.frmaction.verifypeer.disabled = true;
140 document.frmaction.verifyhost.disabled = true;
141 document.frmaction.cainfo.disabled = true;
144 document.frmaction.verifypeer.disabled = false;
145 document.frmaction.verifyhost.disabled = false;
146 document.frmaction.cainfo.disabled = false;
150 function switchauth() {
151 if (document.frmaction.protocol.value != '0') {
152 document.frmaction.authtype.disabled = false;
155 document.frmaction.authtype.disabled = true;
156 document.frmaction.authtype.value = 1;
160 function swicthcainfo() {
161 if (document.frmaction.verifypeer.checked == true) {
162 document.frmaction.cainfo.disabled = false;
165 document.frmaction.cainfo.disabled = true;
169 function switchtransport(is_json) {
171 document.getElementById("idcell").style.visibility = 'hidden';
172 document.frmjsonrpc.yes.checked = false;
173 document.frmxmlrpc.yes.checked = true;
174 document.frmaction.wstype.value = "0";
177 document.getElementById("idcell").style.visibility = 'visible';
178 document.frmjsonrpc.yes.checked = true;
179 document.frmxmlrpc.yes.checked = false;
180 document.frmaction.wstype.value = "1";
184 function displaydialogeditorbtn(show) {
185 if (show && ((typeof base64_decode) == 'function')) {
186 document.getElementById('methodpayloadbtn').innerHTML = '[<a href="#" onclick="activateeditor(); return false;">Edit</a>]';
189 document.getElementById('methodpayloadbtn').innerHTML = '';
193 function activateeditor() {
194 var url = '<?php echo $editorpath; ?>visualeditor.php?params=<?php echo $alt_payload; ?>';
195 if (document.frmaction.wstype.value == "1")
196 url += '&type=jsonrpc';
197 var wnd = window.open(url, '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
200 // if javascript version of the lib is found, allow it to send us params
201 function buildparams(base64data) {
202 if (typeof base64_decode == 'function') {
203 if (base64data == '0') // workaround for bug in base64_encode...
204 document.getElementById('methodpayload').value = '';
206 document.getElementById('methodpayload').value = base64_decode(base64data);
210 // use GET for ease of refresh, switch to POST when payload is too big to fit in url (in IE: 2048 bytes! see http://support.microsoft.com/kb/q208427/)
211 function switchFormMethod() {
212 /// @todo use a more precise calculation, adding the rest of the fields to the actual generated url lenght
213 if (document.frmaction.methodpayload.value.length > 1536) {
214 document.frmaction.action = 'action.php?usepost=true';
215 document.frmaction.method = 'post';
223 onload="switchtransport(<?php echo $wstype; ?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) {
224 echo ' document.forms[2].submit();';
227 <form name="frmxmlrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(0);"/></form>
229 <form name="frmjsonrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(1);"/></form>
230 JSONRPC Debugger (based on the <a href="http://gggeek.github.io/phpxmlrpc/">PHP-XMLRPC</a> library)
232 <form name="frmaction" method="get" action="action.php" target="frmaction" onSubmit="switchFormMethod();">
234 <table id="serverblock">
236 <td><h2>Target server</h2></td>
237 <td class="labelcell">Address:</td>
238 <td><input type="text" name="host" value="<?php echo htmlspecialchars($host); ?>"/></td>
239 <td class="labelcell">Port:</td>
240 <td><input type="text" name="port" value="<?php echo htmlspecialchars($port); ?>" size="5" maxlength="5"/>
242 <td class="labelcell">Path:</td>
243 <td><input type="text" name="path" value="<?php echo htmlspecialchars($path); ?>"/></td>
247 <table id="actionblock">
249 <td><h2>Action</h2></td>
250 <td>List available methods<input type="radio" name="action" value="list"<?php if ($action == 'list') { echo ' checked="checked"'; } ?> onclick="switchaction();"/></td>
251 <td>Describe method<input type="radio" name="action" value="describe"<?php if ($action == 'describe') { echo ' checked="checked"'; } ?> onclick="switchaction();"/></td>
252 <td>Execute method<input type="radio" name="action" value="execute"<?php if ($action == 'execute') { echo ' checked="checked"'; } ?> onclick="switchaction();"/></td>
253 <td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action == 'wrap') { echo ' checked="checked"'; } ?> onclick="switchaction();"/></td>
256 <input type="hidden" name="methodsig" value="<?php echo htmlspecialchars($methodsig); ?>"/>
258 <table id="methodblock">
260 <td><h2>Method</h2></td>
261 <td class="labelcell">Name:</td>
262 <td><input type="text" name="method" value="<?php echo htmlspecialchars($method); ?>"/></td>
263 <td class="labelcell">Payload:<br/>
264 <div id="methodpayloadbtn"></div>
266 <td><textarea id="methodpayload" name="methodpayload" rows="1" cols="40"><?php echo htmlspecialchars($payload); ?></textarea></td>
267 <td class="labelcell" id="idcell">Msg id: <input type="text" name="id" size="3" value="<?php echo htmlspecialchars($id); ?>"/></td>
268 <td><input type="hidden" name="wstype" value="<?php echo $wstype; ?>"/>
269 <input type="submit" value="Execute" onclick="return verifyserver();"/></td>
273 <table id="optionsblock">
275 <td><h2>Client options</h2></td>
276 <td class="labelcell">Show debug info:</td>
277 <td><select name="debug">
278 <option value="0"<?php if ($debug == 0) { echo ' selected="selected"'; } ?>>No</option>
279 <option value="1"<?php if ($debug == 1) { echo ' selected="selected"'; } ?>>Yes</option>
280 <option value="2"<?php if ($debug == 2) { echo ' selected="selected"'; } ?>>More</option>
283 <td class="labelcell">Timeout:</td>
284 <td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) { echo $timeout; } ?>"/></td>
285 <td class="labelcell">Protocol:</td>
286 <td><select name="protocol" onchange="switchssl(); switchauth(); swicthcainfo();">
287 <option value="0"<?php if ($protocol == 0) { echo ' selected="selected"'; } ?>>HTTP 1.0</option>
288 <option value="1"<?php if ($protocol == 1) { echo ' selected="selected"'; } ?>>HTTP 1.1</option>
289 <option value="2"<?php if ($protocol == 2) { echo ' selected="selected"'; } ?>>HTTPS</option>
293 <td class="labelcell">AUTH:</td>
294 <td class="labelcell">Username:</td>
295 <td><input type="text" name="username" value="<?php echo htmlspecialchars($username); ?>"/></td>
296 <td class="labelcell">Pwd:</td>
297 <td><input type="password" name="password" value="<?php echo htmlspecialchars($password); ?>"/></td>
298 <td class="labelcell">Type</td>
299 <td><select name="authtype">
300 <option value="1"<?php if ($authtype == 1) { echo ' selected="selected"'; } ?>>Basic</option>
301 <option value="2"<?php if ($authtype == 2) { echo ' selected="selected"'; } ?>>Digest</option>
302 <option value="8"<?php if ($authtype == 8) { echo ' selected="selected"'; } ?>>NTLM</option>
307 <td class="labelcell">SSL:</td>
308 <td class="labelcell">Verify Host's CN:</td>
309 <td><select name="verifyhost">
310 <option value="0"<?php if ($verifyhost == 0) { echo ' selected="selected"'; } ?>>No</option>
311 <option value="1"<?php if ($verifyhost == 1) { echo ' selected="selected"'; } ?>>Check CN existence</option>
312 <option value="2"<?php if ($verifyhost == 2) { echo ' selected="selected"'; } ?>>Check CN match</option>
314 <td class="labelcell">Verify Cert:</td>
315 <td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) { echo ' checked="checked"'; } ?> /></td>
316 <td class="labelcell">CA Cert file:</td>
317 <td><input type="text" name="cainfo" value="<?php echo htmlspecialchars($cainfo); ?>"/></td>
320 <td class="labelcell">PROXY:</td>
321 <td class="labelcell">Server:</td>
322 <td><input type="text" name="proxy" value="<?php echo htmlspecialchars($proxy); ?>"/></td>
323 <td class="labelcell">Proxy user:</td>
324 <td><input type="text" name="proxyuser" value="<?php echo htmlspecialchars($proxyuser); ?>"/></td>
325 <td class="labelcell">Proxy pwd:</td>
326 <td><input type="password" name="proxypwd" value="<?php echo htmlspecialchars($proxypwd); ?>"/></td>
329 <td class="labelcell">COMPRESSION:</td>
330 <td class="labelcell">Request:</td>
331 <td><select name="requestcompression">
332 <option value="0"<?php if ($requestcompression == 0) { echo ' selected="selected"'; } ?>>None </option>
333 <option value="1"<?php if ($requestcompression == 1) { echo ' selected="selected"'; } ?>>Gzip</option>
334 <option value="2"<?php if ($requestcompression == 2) { echo ' selected="selected"'; } ?>>Deflate</option>
336 <td class="labelcell">Response:</td>
337 <td><select name="responsecompression">
338 <option value="0"<?php if ($responsecompression == 0) { echo ' selected="selected"'; } ?>>None</option>
339 <option value="1"<?php if ($responsecompression == 1) { echo ' selected="selected"'; } ?>>Gzip</option>
340 <option value="2"<?php if ($responsecompression == 2) { echo ' selected="selected"'; } ?>>Deflate</option>
341 <option value="3"<?php if ($responsecompression == 3) { echo ' selected="selected"'; } ?>>Any</option>
346 <td class="labelcell">COOKIES:</td>
347 <td colspan="4" class="labelcell"><input type="text" name="clientcookies" size="80" value="<?php echo htmlspecialchars($clientcookies); ?>"/></td>
348 <td colspan="2">Format: 'cookie1=value1, cookie2=value2'</td>