3 * @author Gaetano Giunta
4 * @copyright (C) 2005-2013 G. Giunta
5 * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/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
12 * @todo parse content of payload textarea to be fed to visual editor
13 * @todo add http no-cache headers
16 include(getcwd().'/common.php');
20 // relative path to the visual xmlrpc editing dialog
21 $editorpath = '../../javascript/';
23 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
24 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
25 <html xmlns="http://www.w3.org/1999/xhtml">
27 <title>XMLRPC Debugger</title>
28 <meta name="robots" content="index,nofollow" />
29 <script type="text/javascript" language="Javascript">
30 if (window.name!='frmcontroller')
31 top.location.replace('index.php?run='+escape(self.location));
33 <!-- xmlrpc/jsonrpc base library -->
34 <script type="text/javascript" src="<?php echo $editorpath; ?>xmlrpc_lib.js"></script>
35 <script type="text/javascript" src="<?php echo $editorpath; ?>jsonrpc_lib.js"></script>
36 <style type="text/css">
38 html {overflow: -moz-scrollbars-vertical;}
39 body {padding: 0.5em; background-color: #EEEEEE; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
40 h1 {font-size: 12pt; margin: 0.5em;}
41 h2 {font-size: 10pt; display: inline; vertical-align: top;}
42 table {border: 1px solid gray; margin-bottom: 0.5em; padding: 0.25em; width: 100%;}
43 #methodpayload {display: inline;}
44 td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
45 .labelcell {text-align: right;}
48 <script language="JavaScript" type="text/javascript">
50 function verifyserver()
52 if (document.frmaction.host.value == '')
54 alert('Please insert a server name or address');
57 if (document.frmaction.path.value == '')
58 document.frmaction.path.value = '/';
60 for (counter = 0; counter < document.frmaction.action.length; counter++)
61 if (document.frmaction.action[counter].checked)
63 action = document.frmaction.action[counter].value;
65 if (document.frmaction.method.value == '' && (action == 'execute' || action == 'wrap' || action == 'describe'))
67 alert('Please insert a method name');
70 if (document.frmaction.authtype.value != '1' && document.frmaction.username.value == '')
72 alert('No username for authenticating to server: authentication disabled');
77 function switchaction()
79 // reset html layout depending on action to be taken
81 for (counter = 0; counter < document.frmaction.action.length; counter++)
82 if (document.frmaction.action[counter].checked)
84 action = document.frmaction.action[counter].value;
86 if (action == 'execute')
88 document.frmaction.methodpayload.disabled = false;
89 displaydialogeditorbtn(true);//if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
90 document.frmaction.method.disabled = false;
91 document.frmaction.methodpayload.rows = 10;
95 document.frmaction.methodpayload.rows = 1;
96 if (action == 'describe' || action == 'wrap')
98 document.frmaction.methodpayload.disabled = true;
99 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = true;
100 document.frmaction.method.disabled = false;
104 document.frmaction.methodpayload.disabled = true;
105 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
106 document.frmaction.method.disabled = true;
113 if (document.frmaction.protocol.value != '2')
115 document.frmaction.verifypeer.disabled = true;
116 document.frmaction.verifyhost.disabled = true;
117 document.frmaction.cainfo.disabled = true;
121 document.frmaction.verifypeer.disabled = false;
122 document.frmaction.verifyhost.disabled = false;
123 document.frmaction.cainfo.disabled = false;
127 function switchauth()
129 if (document.frmaction.protocol.value != '0')
131 document.frmaction.authtype.disabled = false;
135 document.frmaction.authtype.disabled = true;
136 document.frmaction.authtype.value = 1;
140 function swicthcainfo()
142 if (document.frmaction.verifypeer.checked == true)
144 document.frmaction.cainfo.disabled = false;
148 document.frmaction.cainfo.disabled = true;
152 function switchtransport(is_json)
156 document.getElementById("idcell").style.visibility = 'hidden';
157 document.frmjsonrpc.yes.checked = false;
158 document.frmxmlrpc.yes.checked = true;
159 document.frmaction.wstype.value="0";
163 document.getElementById("idcell").style.visibility = 'visible';
164 document.frmjsonrpc.yes.checked = true;
165 document.frmxmlrpc.yes.checked = false;
166 document.frmaction.wstype.value="1";
170 function displaydialogeditorbtn(show)
172 if (show && ((typeof base64_decode) == 'function'))
174 document.getElementById('methodpayloadbtn').innerHTML = '[<a href="#" onclick="activateeditor(); return false;">Edit</a>]';
178 document.getElementById('methodpayloadbtn').innerHTML = '';
182 function activateeditor()
184 var url = '<?php echo $editorpath; ?>visualeditor.php?params=<?php echo $alt_payload; ?>';
185 if (document.frmaction.wstype.value == "1")
186 url += '&type=jsonrpc';
187 var wnd = window.open(url, '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
190 // if javascript version of the lib is found, allow it to send us params
191 function buildparams(base64data)
193 if (typeof base64_decode == 'function')
195 if (base64data == '0') // workaround for bug in base64_encode...
196 document.getElementById('methodpayload').value = '';
198 document.getElementById('methodpayload').value = base64_decode(base64data);
202 // 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/)
203 function switchFormMethod()
205 /// @todo use a more precise calculation, adding the rest of the fields to the actual generated url lenght
206 if (document.frmaction.methodpayload.value.length > 1536 )
208 document.frmaction.action = 'action.php?usepost=true';
209 document.frmaction.method = 'post';
216 <body onload="switchtransport(<?php echo $wstype;?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) echo ' document.forms[2].submit();'; ?>">
217 <h1>XMLRPC <form name="frmxmlrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(0);"/></form>
218 /<form name="frmjsonrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(1);"/></form>JSONRPC Debugger (based on the <a href="http://phpxmlrpc.sourceforge.net">PHP-XMLRPC</a> library)</h1>
219 <form name="frmaction" method="get" action="action.php" target="frmaction" onSubmit="switchFormMethod();"
222 <table id="serverblock">
224 <td><h2>Target server</h2></td>
225 <td class="labelcell">Address:</td><td><input type="text" name="host" value="<?php echo htmlspecialchars($host); ?>" /></td>
226 <td class="labelcell">Port:</td><td><input type="text" name="port" value="<?php echo htmlspecialchars($port); ?>" size="5" maxlength="5" /></td>
227 <td class="labelcell">Path:</td><td><input type="text" name="path" value="<?php echo htmlspecialchars($path); ?>" /></td>
231 <table id="actionblock">
233 <td><h2>Action</h2></td>
234 <td>List available methods<input type="radio" name="action" value="list"<?php if ($action=='list') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
235 <td>Describe method<input type="radio" name="action" value="describe"<?php if ($action=='describe') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
236 <td>Execute method<input type="radio" name="action" value="execute"<?php if ($action=='execute') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
237 <td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action=='wrap') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
240 <input type="hidden" name="methodsig" value="<?php echo htmlspecialchars($methodsig); ?>" />
242 <table id="methodblock">
244 <td><h2>Method</h2></td>
245 <td class="labelcell">Name:</td><td><input type="text" name="method" value="<?php echo htmlspecialchars($method); ?>" /></td>
246 <td class="labelcell">Payload:<br/><div id="methodpayloadbtn"></div></td><td><textarea id="methodpayload" name="methodpayload" rows="1" cols="40"><?php echo htmlspecialchars($payload); ?></textarea></td>
247 <td class="labelcell" id="idcell">Msg id: <input type="text" name="id" size="3" value="<?php echo htmlspecialchars($id); ?>"/></td>
248 <td><input type="hidden" name="wstype" value="<?php echo $wstype;?>" />
249 <input type="submit" value="Execute" onclick="return verifyserver();"/></td>
253 <table id="optionsblock">
255 <td><h2>Client options</h2></td>
256 <td class="labelcell">Show debug info:</td><td><select name="debug">
257 <option value="0"<?php if ($debug == 0) echo ' selected="selected"'; ?>>No</option>
258 <option value="1"<?php if ($debug == 1) echo ' selected="selected"'; ?>>Yes</option>
259 <option value="2"<?php if ($debug == 2) echo ' selected="selected"'; ?>>More</option>
262 <td class="labelcell">Timeout:</td><td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) echo $timeout; ?>" /></td>
263 <td class="labelcell">Protocol:</td><td><select name="protocol" onchange="switchssl(); switchauth(); swicthcainfo();">
264 <option value="0"<?php if ($protocol == 0) echo ' selected="selected"'; ?>>HTTP 1.0</option>
265 <option value="1"<?php if ($protocol == 1) echo ' selected="selected"'; ?>>HTTP 1.1</option>
266 <option value="2"<?php if ($protocol == 2) echo ' selected="selected"'; ?>>HTTPS</option>
270 <td class="labelcell">AUTH:</td>
271 <td class="labelcell">Username:</td><td><input type="text" name="username" value="<?php echo htmlspecialchars($username); ?>" /></td>
272 <td class="labelcell">Pwd:</td><td><input type="password" name="password" value="<?php echo htmlspecialchars($password); ?>" /></td>
273 <td class="labelcell">Type</td><td><select name="authtype">
274 <option value="1"<?php if ($authtype == 1) echo ' selected="selected"'; ?>>Basic</option>
275 <option value="2"<?php if ($authtype == 2) echo ' selected="selected"'; ?>>Digest</option>
276 <option value="8"<?php if ($authtype == 8) echo ' selected="selected"'; ?>>NTLM</option>
281 <td class="labelcell">SSL:</td>
282 <td class="labelcell">Verify Host's CN:</td><td><select name="verifyhost">
283 <option value="0"<?php if ($verifyhost == 0) echo ' selected="selected"'; ?>>No</option>
284 <option value="1"<?php if ($verifyhost == 1) echo ' selected="selected"'; ?>>Check CN existance</option>
285 <option value="2"<?php if ($verifyhost == 2) echo ' selected="selected"'; ?>>Check CN match</option>
287 <td class="labelcell">Verify Cert:</td><td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) echo ' checked="checked"'; ?> /></td>
288 <td class="labelcell">CA Cert file:</td><td><input type="text" name="cainfo" value="<?php echo htmlspecialchars($cainfo); ?>" /></td>
291 <td class="labelcell">PROXY:</td>
292 <td class="labelcell">Server:</td><td><input type="text" name="proxy" value="<?php echo htmlspecialchars($proxy); ?>" /></td>
293 <td class="labelcell">Proxy user:</td><td><input type="text" name="proxyuser" value="<?php echo htmlspecialchars($proxyuser); ?>" /></td>
294 <td class="labelcell">Proxy pwd:</td><td><input type="password" name="proxypwd" value="<?php echo htmlspecialchars($proxypwd); ?>" /></td>
297 <td class="labelcell">COMPRESSION:</td>
298 <td class="labelcell">Request:</td><td><select name="requestcompression">
299 <option value="0"<?php if ($requestcompression == 0) echo ' selected="selected"'; ?>>None</option>
300 <option value="1"<?php if ($requestcompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
301 <option value="2"<?php if ($requestcompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
303 <td class="labelcell">Response:</td><td><select name="responsecompression">
304 <option value="0"<?php if ($responsecompression == 0) echo ' selected="selected"'; ?>>None</option>
305 <option value="1"<?php if ($responsecompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
306 <option value="2"<?php if ($responsecompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
307 <option value="3"<?php if ($responsecompression == 3) echo ' selected="selected"'; ?>>Any</option>
312 <td class="labelcell">COOKIES:</td>
313 <td colspan="4" class="labelcell"><input type="text" name="clientcookies" size="80" value="<?php echo htmlspecialchars($clientcookies); ?>" /></td>
314 <td colspan="2">Format: 'cookie1=value1, cookie2=value2'</td>