4 * @author Gaetano Giunta
5 * @copyright (C) 2005-2008 G. Giunta
6 * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
8 * @todo add links to documentation from every option caption
9 * @todo switch params for http compression from 0,1,2 to values to be used directly
10 * @todo add a little bit more CSS formatting: we broke IE box model getting a width > 100%...
11 * @todo add support for more options, such as ntlm auth to proxy, or request charset encoding
13 * @todo parse content of payload textarea to be fed to visual editor
14 * @todo add http no-cache headers
17 include(getcwd().'/common.php');
21 // relative path to the visual xmlrpc editing dialog
22 $editorpath = '../../javascript/';
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 $editorpath; ?>xmlrpc_lib.js"></script>
36 <script type="text/javascript" src="<?php echo $editorpath; ?>jsonrpc_lib.js"></script>
37 <style type="text/css">
39 html {overflow: -moz-scrollbars-vertical;}
40 body {padding: 0.5em; background-color: #EEEEEE; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
41 h1 {font-size: 12pt; margin: 0.5em;}
42 h2 {font-size: 10pt; display: inline; vertical-align: top;}
43 table {border: 1px solid gray; margin-bottom: 0.5em; padding: 0.25em; width: 100%;}
44 #methodpayload {display: inline;}
45 td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
46 .labelcell {text-align: right;}
49 <script language="JavaScript" type="text/javascript">
51 function verifyserver()
53 if (document.frmaction.host.value == '')
55 alert('Please insert a server name or address');
58 if (document.frmaction.path.value == '')
59 document.frmaction.path.value = '/';
61 for (counter = 0; counter < document.frmaction.action.length; counter++)
62 if (document.frmaction.action[counter].checked)
64 action = document.frmaction.action[counter].value;
66 if (document.frmaction.method.value == '' && (action == 'execute' || action == 'wrap' || action == 'describe'))
68 alert('Please insert a method name');
71 if (document.frmaction.authtype.value != '1' && document.frmaction.username.value == '')
73 alert('No username for authenticating to server: authentication disabled');
78 function switchaction()
80 // reset html layout depending on action to be taken
82 for (counter = 0; counter < document.frmaction.action.length; counter++)
83 if (document.frmaction.action[counter].checked)
85 action = document.frmaction.action[counter].value;
87 if (action == 'execute')
89 document.frmaction.methodpayload.disabled = false;
90 displaydialogeditorbtn(true);//if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
91 document.frmaction.method.disabled = false;
92 document.frmaction.methodpayload.rows = 10;
96 document.frmaction.methodpayload.rows = 1;
97 if (action == 'describe' || action == 'wrap')
99 document.frmaction.methodpayload.disabled = true;
100 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = true;
101 document.frmaction.method.disabled = false;
105 document.frmaction.methodpayload.disabled = true;
106 displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
107 document.frmaction.method.disabled = true;
114 if (document.frmaction.protocol.value != '2')
116 document.frmaction.verifypeer.disabled = true;
117 document.frmaction.verifyhost.disabled = true;
118 document.frmaction.cainfo.disabled = true;
122 document.frmaction.verifypeer.disabled = false;
123 document.frmaction.verifyhost.disabled = false;
124 document.frmaction.cainfo.disabled = false;
128 function switchauth()
130 if (document.frmaction.protocol.value != '0')
132 document.frmaction.authtype.disabled = false;
136 document.frmaction.authtype.disabled = true;
137 document.frmaction.authtype.value = 1;
141 function swicthcainfo()
143 if (document.frmaction.verifypeer.checked == true)
145 document.frmaction.cainfo.disabled = false;
149 document.frmaction.cainfo.disabled = true;
153 function switchtransport(is_json)
157 document.getElementById("idcell").style.visibility = 'hidden';
158 document.frmjsonrpc.yes.checked = false;
159 document.frmxmlrpc.yes.checked = true;
160 document.frmaction.wstype.value="0";
164 document.getElementById("idcell").style.visibility = 'visible';
165 document.frmjsonrpc.yes.checked = true;
166 document.frmxmlrpc.yes.checked = false;
167 document.frmaction.wstype.value="1";
171 function displaydialogeditorbtn(show)
173 if (show && ((typeof base64_decode) == 'function'))
175 document.getElementById('methodpayloadbtn').innerHTML = '[<a href="#" onclick="activateeditor(); return false;">Edit</a>]';
179 document.getElementById('methodpayloadbtn').innerHTML = '';
183 function activateeditor()
185 var url = '<?php echo $editorpath; ?>visualeditor.php?params=<?php echo $alt_payload; ?>';
186 if (document.frmaction.wstype.value == "1")
187 url += '&type=jsonrpc';
188 var wnd = window.open(url, '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
191 // if javascript version of the lib is found, allow it to send us params
192 function buildparams(base64data)
194 if (typeof base64_decode == 'function')
196 if (base64data == '0') // workaround for bug in base64_encode...
197 document.getElementById('methodpayload').value = '';
199 document.getElementById('methodpayload').value = base64_decode(base64data);
203 // 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/)
204 function switchFormMethod()
206 /// @todo use a more precise calculation, adding the rest of the fields to the actual generated url lenght
207 if (document.frmaction.methodpayload.value.length > 1536 )
209 document.frmaction.action = 'action.php?usepost=true';
210 document.frmaction.method = 'post';
217 <body onload="switchtransport(<?php echo $wstype;?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) echo ' document.forms[2].submit();'; ?>">
218 <h1>XMLRPC <form name="frmxmlrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(0);"/></form>
219 /<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>
220 <form name="frmaction" method="get" action="action.php" target="frmaction" onSubmit="switchFormMethod();"
223 <table id="serverblock">
225 <td><h2>Target server</h2></td>
226 <td class="labelcell">Address:</td><td><input type="text" name="host" value="<?php echo htmlspecialchars($host); ?>" /></td>
227 <td class="labelcell">Port:</td><td><input type="text" name="port" value="<?php echo htmlspecialchars($port); ?>" size="5" maxlength="5" /></td>
228 <td class="labelcell">Path:</td><td><input type="text" name="path" value="<?php echo htmlspecialchars($path); ?>" /></td>
232 <table id="actionblock">
234 <td><h2>Action</h2></td>
235 <td>List available methods<input type="radio" name="action" value="list"<?php if ($action=='list') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
236 <td>Describe method<input type="radio" name="action" value="describe"<?php if ($action=='describe') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
237 <td>Execute method<input type="radio" name="action" value="execute"<?php if ($action=='execute') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
238 <td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action=='wrap') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
241 <input type="hidden" name="methodsig" value="<?php echo htmlspecialchars($methodsig); ?>" />
243 <table id="methodblock">
245 <td><h2>Method</h2></td>
246 <td class="labelcell">Name:</td><td><input type="text" name="method" value="<?php echo htmlspecialchars($method); ?>" /></td>
247 <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>
248 <td class="labelcell" id="idcell">Msg id: <input type="text" name="id" size="3" value="<?php echo htmlspecialchars($id); ?>"/></td>
249 <td><input type="hidden" name="wstype" value="<?php echo $wstype;?>" />
250 <input type="submit" value="Execute" onclick="return verifyserver();"/></td>
254 <table id="optionsblock">
256 <td><h2>Client options</h2></td>
257 <td class="labelcell">Show debug info:</td><td><select name="debug">
258 <option value="0"<?php if ($debug == 0) echo ' selected="selected"'; ?>>No</option>
259 <option value="1"<?php if ($debug == 1) echo ' selected="selected"'; ?>>Yes</option>
260 <option value="2"<?php if ($debug == 2) echo ' selected="selected"'; ?>>More</option>
263 <td class="labelcell">Timeout:</td><td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) echo $timeout; ?>" /></td>
264 <td class="labelcell">Protocol:</td><td><select name="protocol" onchange="switchssl(); switchauth(); swicthcainfo();">
265 <option value="0"<?php if ($protocol == 0) echo ' selected="selected"'; ?>>HTTP 1.0</option>
266 <option value="1"<?php if ($protocol == 1) echo ' selected="selected"'; ?>>HTTP 1.1</option>
267 <option value="2"<?php if ($protocol == 2) echo ' selected="selected"'; ?>>HTTPS</option>
271 <td class="labelcell">AUTH:</td>
272 <td class="labelcell">Username:</td><td><input type="text" name="username" value="<?php echo htmlspecialchars($username); ?>" /></td>
273 <td class="labelcell">Pwd:</td><td><input type="password" name="password" value="<?php echo htmlspecialchars($password); ?>" /></td>
274 <td class="labelcell">Type</td><td><select name="authtype">
275 <option value="1"<?php if ($authtype == 1) echo ' selected="selected"'; ?>>Basic</option>
276 <option value="2"<?php if ($authtype == 2) echo ' selected="selected"'; ?>>Digest</option>
277 <option value="8"<?php if ($authtype == 8) echo ' selected="selected"'; ?>>NTLM</option>
282 <td class="labelcell">SSL:</td>
283 <td class="labelcell">Verify Host's CN:</td><td><select name="verifyhost">
284 <option value="0"<?php if ($verifyhost == 0) echo ' selected="selected"'; ?>>No</option>
285 <option value="1"<?php if ($verifyhost == 1) echo ' selected="selected"'; ?>>Check CN existance</option>
286 <option value="2"<?php if ($verifyhost == 2) echo ' selected="selected"'; ?>>Check CN match</option>
288 <td class="labelcell">Verify Cert:</td><td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) echo ' checked="checked"'; ?> /></td>
289 <td class="labelcell">CA Cert file:</td><td><input type="text" name="cainfo" value="<?php echo htmlspecialchars($cainfo); ?>" /></td>
292 <td class="labelcell">PROXY:</td>
293 <td class="labelcell">Server:</td><td><input type="text" name="proxy" value="<?php echo htmlspecialchars($proxy); ?>" /></td>
294 <td class="labelcell">Proxy user:</td><td><input type="text" name="proxyuser" value="<?php echo htmlspecialchars($proxyuser); ?>" /></td>
295 <td class="labelcell">Proxy pwd:</td><td><input type="password" name="proxypwd" value="<?php echo htmlspecialchars($proxypwd); ?>" /></td>
298 <td class="labelcell">COMPRESSION:</td>
299 <td class="labelcell">Request:</td><td><select name="requestcompression">
300 <option value="0"<?php if ($requestcompression == 0) echo ' selected="selected"'; ?>>None</option>
301 <option value="1"<?php if ($requestcompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
302 <option value="2"<?php if ($requestcompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
304 <td class="labelcell">Response:</td><td><select name="responsecompression">
305 <option value="0"<?php if ($responsecompression == 0) echo ' selected="selected"'; ?>>None</option>
306 <option value="1"<?php if ($responsecompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
307 <option value="2"<?php if ($responsecompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
308 <option value="3"<?php if ($responsecompression == 3) echo ' selected="selected"'; ?>>Any</option>
313 <td class="labelcell">COOKIES:</td>
314 <td colspan="4" class="labelcell"><input type="text" name="clientcookies" size="80" value="<?php echo htmlspecialchars($clientcookies); ?>" /></td>
315 <td colspan="2">Format: 'cookie1=value1, cookie2=value2'</td>